18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 11
70#define NLOHMANN_JSON_VERSION_PATCH 3
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
77 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
81 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
83 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
86#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
87 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
89 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
92#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
93 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
97#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
98#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
99 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
101#define NLOHMANN_JSON_ABI_TAGS \
102 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
103 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
104 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
107#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
108 _v ## major ## _ ## minor ## _ ## patch
109#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
110 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
112#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
113#define NLOHMANN_JSON_NAMESPACE_VERSION
115#define NLOHMANN_JSON_NAMESPACE_VERSION \
116 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
117 NLOHMANN_JSON_VERSION_MINOR, \
118 NLOHMANN_JSON_VERSION_PATCH)
122#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
123#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
124 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
126#ifndef NLOHMANN_JSON_NAMESPACE
127#define NLOHMANN_JSON_NAMESPACE \
128 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
129 NLOHMANN_JSON_ABI_TAGS, \
130 NLOHMANN_JSON_NAMESPACE_VERSION)
133#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
134#define NLOHMANN_JSON_NAMESPACE_BEGIN \
137 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
138 NLOHMANN_JSON_ABI_TAGS, \
139 NLOHMANN_JSON_NAMESPACE_VERSION) \
143#ifndef NLOHMANN_JSON_NAMESPACE_END
144#define NLOHMANN_JSON_NAMESPACE_END \
162#include <forward_list>
165#ifdef JSON_HAS_CPP_17
170#include <type_traits>
171#include <unordered_map>
235#include <type_traits>
280template<
class Default,
282 template<
class...>
class Op,
290template<
class Default,
template<
class...>
class Op,
class... Args>
297template<
template<
class...>
class Op,
class... Args>
300template<
template<
class...>
class Op,
class... Args>
303template<
template<
class...>
class Op,
class... Args>
306template<
class Default,
template<
class...>
class Op,
class... Args>
309template<
class Default,
template<
class...>
class Op,
class... Args>
312template<
class Expected,
template<
class...>
class Op,
class... Args>
315template<
class To,
template<
class...>
class Op,
class... Args>
317 std::is_convertible<
detected_t<Op, Args...>, To>;
338#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
339#if defined(JSON_HEDLEY_VERSION)
340 #undef JSON_HEDLEY_VERSION
342#define JSON_HEDLEY_VERSION 15
344#if defined(JSON_HEDLEY_STRINGIFY_EX)
345 #undef JSON_HEDLEY_STRINGIFY_EX
347#define JSON_HEDLEY_STRINGIFY_EX(x) #x
349#if defined(JSON_HEDLEY_STRINGIFY)
350 #undef JSON_HEDLEY_STRINGIFY
352#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
354#if defined(JSON_HEDLEY_CONCAT_EX)
355 #undef JSON_HEDLEY_CONCAT_EX
357#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
359#if defined(JSON_HEDLEY_CONCAT)
360 #undef JSON_HEDLEY_CONCAT
362#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
364#if defined(JSON_HEDLEY_CONCAT3_EX)
365 #undef JSON_HEDLEY_CONCAT3_EX
367#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
369#if defined(JSON_HEDLEY_CONCAT3)
370 #undef JSON_HEDLEY_CONCAT3
372#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
374#if defined(JSON_HEDLEY_VERSION_ENCODE)
375 #undef JSON_HEDLEY_VERSION_ENCODE
377#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
379#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
380 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
382#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
384#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
385 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
387#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
389#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
390 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
392#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
394#if defined(JSON_HEDLEY_GNUC_VERSION)
395 #undef JSON_HEDLEY_GNUC_VERSION
397#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
398 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
399#elif defined(__GNUC__)
400 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
403#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
404 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
406#if defined(JSON_HEDLEY_GNUC_VERSION)
407 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
409 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
412#if defined(JSON_HEDLEY_MSVC_VERSION)
413 #undef JSON_HEDLEY_MSVC_VERSION
415#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
416 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
417#elif defined(_MSC_FULL_VER) && !defined(__ICL)
418 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
419#elif defined(_MSC_VER) && !defined(__ICL)
420 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
423#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
424 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
426#if !defined(JSON_HEDLEY_MSVC_VERSION)
427 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
428#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
429 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
430#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
431 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
433 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
436#if defined(JSON_HEDLEY_INTEL_VERSION)
437 #undef JSON_HEDLEY_INTEL_VERSION
439#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
440 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
441#elif defined(__INTEL_COMPILER) && !defined(__ICL)
442 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
445#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
446 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
448#if defined(JSON_HEDLEY_INTEL_VERSION)
449 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
451 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
454#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
455 #undef JSON_HEDLEY_INTEL_CL_VERSION
457#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
458 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
461#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
462 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
464#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
465 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
467 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
470#if defined(JSON_HEDLEY_PGI_VERSION)
471 #undef JSON_HEDLEY_PGI_VERSION
473#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
474 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
477#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
478 #undef JSON_HEDLEY_PGI_VERSION_CHECK
480#if defined(JSON_HEDLEY_PGI_VERSION)
481 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
483 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
486#if defined(JSON_HEDLEY_SUNPRO_VERSION)
487 #undef JSON_HEDLEY_SUNPRO_VERSION
489#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
490 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
491#elif defined(__SUNPRO_C)
492 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
493#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
494 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
495#elif defined(__SUNPRO_CC)
496 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
499#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
500 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
502#if defined(JSON_HEDLEY_SUNPRO_VERSION)
503 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
505 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
508#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
509 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
511#if defined(__EMSCRIPTEN__)
512 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
515#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
516 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
518#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
519 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
521 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
524#if defined(JSON_HEDLEY_ARM_VERSION)
525 #undef JSON_HEDLEY_ARM_VERSION
527#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
528 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
529#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
530 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
533#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
534 #undef JSON_HEDLEY_ARM_VERSION_CHECK
536#if defined(JSON_HEDLEY_ARM_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
539 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
542#if defined(JSON_HEDLEY_IBM_VERSION)
543 #undef JSON_HEDLEY_IBM_VERSION
545#if defined(__ibmxl__)
546 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
547#elif defined(__xlC__) && defined(__xlC_ver__)
548 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
549#elif defined(__xlC__)
550 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
553#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
554 #undef JSON_HEDLEY_IBM_VERSION_CHECK
556#if defined(JSON_HEDLEY_IBM_VERSION)
557 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
559 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
562#if defined(JSON_HEDLEY_TI_VERSION)
563 #undef JSON_HEDLEY_TI_VERSION
566 defined(__TI_COMPILER_VERSION__) && \
568 defined(__TMS470__) || defined(__TI_ARM__) || \
569 defined(__MSP430__) || \
570 defined(__TMS320C2000__) \
572#if (__TI_COMPILER_VERSION__ >= 16000000)
573 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
577#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
578 #undef JSON_HEDLEY_TI_VERSION_CHECK
580#if defined(JSON_HEDLEY_TI_VERSION)
581 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
583 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
586#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
587 #undef JSON_HEDLEY_TI_CL2000_VERSION
589#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
590 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
593#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
594 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
596#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
597 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
599 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
602#if defined(JSON_HEDLEY_TI_CL430_VERSION)
603 #undef JSON_HEDLEY_TI_CL430_VERSION
605#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
606 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
609#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
610 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
612#if defined(JSON_HEDLEY_TI_CL430_VERSION)
613 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
615 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
618#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
619 #undef JSON_HEDLEY_TI_ARMCL_VERSION
621#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
622 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
625#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
626 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
628#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
629 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
631 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
634#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
635 #undef JSON_HEDLEY_TI_CL6X_VERSION
637#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
638 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
641#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
642 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
644#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
645 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
647 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
650#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
651 #undef JSON_HEDLEY_TI_CL7X_VERSION
653#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
654 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
657#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
658 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
660#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
661 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
663 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
666#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
667 #undef JSON_HEDLEY_TI_CLPRU_VERSION
669#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
670 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
673#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
674 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
676#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
677 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
679 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
682#if defined(JSON_HEDLEY_CRAY_VERSION)
683 #undef JSON_HEDLEY_CRAY_VERSION
686 #if defined(_RELEASE_PATCHLEVEL)
687 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
689 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
693#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
694 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
696#if defined(JSON_HEDLEY_CRAY_VERSION)
697 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
699 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
702#if defined(JSON_HEDLEY_IAR_VERSION)
703 #undef JSON_HEDLEY_IAR_VERSION
705#if defined(__IAR_SYSTEMS_ICC__)
707 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
709 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
713#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
714 #undef JSON_HEDLEY_IAR_VERSION_CHECK
716#if defined(JSON_HEDLEY_IAR_VERSION)
717 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
719 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
722#if defined(JSON_HEDLEY_TINYC_VERSION)
723 #undef JSON_HEDLEY_TINYC_VERSION
725#if defined(__TINYC__)
726 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
729#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
730 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
732#if defined(JSON_HEDLEY_TINYC_VERSION)
733 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
735 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
738#if defined(JSON_HEDLEY_DMC_VERSION)
739 #undef JSON_HEDLEY_DMC_VERSION
742 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
745#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
746 #undef JSON_HEDLEY_DMC_VERSION_CHECK
748#if defined(JSON_HEDLEY_DMC_VERSION)
749 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
751 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
754#if defined(JSON_HEDLEY_COMPCERT_VERSION)
755 #undef JSON_HEDLEY_COMPCERT_VERSION
757#if defined(__COMPCERT_VERSION__)
758 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
761#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
762 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
764#if defined(JSON_HEDLEY_COMPCERT_VERSION)
765 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
767 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
770#if defined(JSON_HEDLEY_PELLES_VERSION)
771 #undef JSON_HEDLEY_PELLES_VERSION
774 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
777#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
778 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
780#if defined(JSON_HEDLEY_PELLES_VERSION)
781 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
783 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
786#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
787 #undef JSON_HEDLEY_MCST_LCC_VERSION
789#if defined(__LCC__) && defined(__LCC_MINOR__)
790 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
793#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
794 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
796#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
797 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
799 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
802#if defined(JSON_HEDLEY_GCC_VERSION)
803 #undef JSON_HEDLEY_GCC_VERSION
806 defined(JSON_HEDLEY_GNUC_VERSION) && \
807 !defined(__clang__) && \
808 !defined(JSON_HEDLEY_INTEL_VERSION) && \
809 !defined(JSON_HEDLEY_PGI_VERSION) && \
810 !defined(JSON_HEDLEY_ARM_VERSION) && \
811 !defined(JSON_HEDLEY_CRAY_VERSION) && \
812 !defined(JSON_HEDLEY_TI_VERSION) && \
813 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
814 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
815 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
816 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
817 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
818 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
819 !defined(__COMPCERT__) && \
820 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
821 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
824#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
825 #undef JSON_HEDLEY_GCC_VERSION_CHECK
827#if defined(JSON_HEDLEY_GCC_VERSION)
828 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
830 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
833#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
834 #undef JSON_HEDLEY_HAS_ATTRIBUTE
837 defined(__has_attribute) && \
839 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
841# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
843# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
846#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
847 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
849#if defined(__has_attribute)
850 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
852 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
855#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
856 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
858#if defined(__has_attribute)
859 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
861 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
864#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
865 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
868 defined(__has_cpp_attribute) && \
869 defined(__cplusplus) && \
870 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
871 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
873 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
876#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
877 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
879#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
882 !defined(JSON_HEDLEY_PGI_VERSION) && \
883 !defined(JSON_HEDLEY_IAR_VERSION) && \
884 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
885 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
886 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
888 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
891#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
892 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
894#if defined(__has_cpp_attribute) && defined(__cplusplus)
895 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
897 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
900#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
901 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
903#if defined(__has_cpp_attribute) && defined(__cplusplus)
904 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
906 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
909#if defined(JSON_HEDLEY_HAS_BUILTIN)
910 #undef JSON_HEDLEY_HAS_BUILTIN
912#if defined(__has_builtin)
913 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
915 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
918#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
919 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
921#if defined(__has_builtin)
922 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
924 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
927#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
928 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
930#if defined(__has_builtin)
931 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
933 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
936#if defined(JSON_HEDLEY_HAS_FEATURE)
937 #undef JSON_HEDLEY_HAS_FEATURE
939#if defined(__has_feature)
940 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
942 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
945#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
946 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
948#if defined(__has_feature)
949 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
951 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
954#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
955 #undef JSON_HEDLEY_GCC_HAS_FEATURE
957#if defined(__has_feature)
958 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
960 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
963#if defined(JSON_HEDLEY_HAS_EXTENSION)
964 #undef JSON_HEDLEY_HAS_EXTENSION
966#if defined(__has_extension)
967 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
969 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
972#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
973 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
975#if defined(__has_extension)
976 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
978 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
981#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
982 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
984#if defined(__has_extension)
985 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
987 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
990#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
991 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
993#if defined(__has_declspec_attribute)
994 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
996 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
999#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1000 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1002#if defined(__has_declspec_attribute)
1003 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1005 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1008#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1009 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1011#if defined(__has_declspec_attribute)
1012 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1014 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1017#if defined(JSON_HEDLEY_HAS_WARNING)
1018 #undef JSON_HEDLEY_HAS_WARNING
1020#if defined(__has_warning)
1021 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1023 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1026#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1027 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1029#if defined(__has_warning)
1030 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1032 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1035#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1036 #undef JSON_HEDLEY_GCC_HAS_WARNING
1038#if defined(__has_warning)
1039 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1041 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1045 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1046 defined(__clang__) || \
1047 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1048 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1049 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1050 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1051 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1052 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1053 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1054 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1055 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1056 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1057 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1058 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1059 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1060 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1061 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1062 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1063 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1064#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1065 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1067 #define JSON_HEDLEY_PRAGMA(value)
1070#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1071 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1073#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1074 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1076#if defined(__clang__)
1077 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1078 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1079#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1080 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1081 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1082#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1083 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1084 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1086 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1087 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1088 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1089 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1090#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1091 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1092 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1094 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1095 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1096 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1097 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1098 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1099 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1100 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1101 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1102#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1103 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1104 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1106 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1107 #define JSON_HEDLEY_DIAGNOSTIC_POP
1112#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1113 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1115#if defined(__cplusplus)
1116# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1117# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1118# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1119# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1120 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1121 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1122 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1123 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1125 JSON_HEDLEY_DIAGNOSTIC_POP
1127# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1128 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1129 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1130 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1132 JSON_HEDLEY_DIAGNOSTIC_POP
1135# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1136 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1137 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1139 JSON_HEDLEY_DIAGNOSTIC_POP
1143#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1144 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1147#if defined(JSON_HEDLEY_CONST_CAST)
1148 #undef JSON_HEDLEY_CONST_CAST
1150#if defined(__cplusplus)
1151# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1153 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1154 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1155 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1156# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1157 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1158 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1160 JSON_HEDLEY_DIAGNOSTIC_POP \
1163# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1166#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1167 #undef JSON_HEDLEY_REINTERPRET_CAST
1169#if defined(__cplusplus)
1170 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1172 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1175#if defined(JSON_HEDLEY_STATIC_CAST)
1176 #undef JSON_HEDLEY_STATIC_CAST
1178#if defined(__cplusplus)
1179 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1181 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1184#if defined(JSON_HEDLEY_CPP_CAST)
1185 #undef JSON_HEDLEY_CPP_CAST
1187#if defined(__cplusplus)
1188# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1189# define JSON_HEDLEY_CPP_CAST(T, expr) \
1190 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1191 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1193 JSON_HEDLEY_DIAGNOSTIC_POP
1194# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1195# define JSON_HEDLEY_CPP_CAST(T, expr) \
1196 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1197 _Pragma("diag_suppress=Pe137") \
1198 JSON_HEDLEY_DIAGNOSTIC_POP
1200# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1203# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1206#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1207 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1209#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1211#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1213#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1215#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1217#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1219#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1221#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1222 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1223#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1224 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1226 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1227 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1229 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1231 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1232 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1233 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1234 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1235 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1236 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1238#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1239 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1240#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1241 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1242#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1244#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1245 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1247 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1250#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1251 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1253#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1255#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1257#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1259#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1261#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1262 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1263#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1264 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1266 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1267 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1268 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1269 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1271#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1273#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1275#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1276 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1278 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1281#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1282 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1284#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1286#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1288#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1289 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1290#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1292#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1294#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1296#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1297 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1298#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1299 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1301 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1302 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1303 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1305#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1307#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1308 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1310 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1313#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1314 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1316#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1318#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1320#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1321 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1323 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1326#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1327 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1329#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1331#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1333#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1334 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1335#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1336 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1338 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1341#if defined(JSON_HEDLEY_DEPRECATED)
1342 #undef JSON_HEDLEY_DEPRECATED
1344#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1345 #undef JSON_HEDLEY_DEPRECATED_FOR
1348 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1349 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1350 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1351 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1353 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1354 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1355 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1356 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1357 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1358 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1359 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1360 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1361 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1362 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1363 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1364 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1365 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1366 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1367#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1368 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1369 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1371 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1372 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1373 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1374 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1375 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1376 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1377 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1378 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1379 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1380 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1381 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1382 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1383 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1384 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1385 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1386 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1387 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1388 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1390 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1391 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1392 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1393 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1394 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1395#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1396 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1397 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1399 #define JSON_HEDLEY_DEPRECATED(since)
1400 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1403#if defined(JSON_HEDLEY_UNAVAILABLE)
1404 #undef JSON_HEDLEY_UNAVAILABLE
1407 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1408 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1409 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1410 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1411 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1413 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1416#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1417 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1419#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1420 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1423 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1424 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1425 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1426 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1427 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1428 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1429 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1430 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1431 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1432 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1433 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1434 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1435 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1436 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1437 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1438 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1439 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1440 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1441 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1442#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1443 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1444 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1445#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1446 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1448#elif defined(_Check_return_)
1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1452 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1456#if defined(JSON_HEDLEY_SENTINEL)
1457 #undef JSON_HEDLEY_SENTINEL
1460 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1461 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1462 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1463 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1464 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1465 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1467 #define JSON_HEDLEY_SENTINEL(position)
1470#if defined(JSON_HEDLEY_NO_RETURN)
1471 #undef JSON_HEDLEY_NO_RETURN
1473#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1474 #define JSON_HEDLEY_NO_RETURN __noreturn
1476 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1477 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1478 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1479#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1480 #define JSON_HEDLEY_NO_RETURN _Noreturn
1481#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1482 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1484 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1485 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1486 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1487 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1488 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1489 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1490 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1492 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1493 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1494 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1495 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1496 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1497 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1498 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1499 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1500 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1501 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1502#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1503 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1505 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1506 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1507 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1508#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1509 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1510#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1511 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1512#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1513 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1515 #define JSON_HEDLEY_NO_RETURN
1518#if defined(JSON_HEDLEY_NO_ESCAPE)
1519 #undef JSON_HEDLEY_NO_ESCAPE
1521#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1522 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1524 #define JSON_HEDLEY_NO_ESCAPE
1527#if defined(JSON_HEDLEY_UNREACHABLE)
1528 #undef JSON_HEDLEY_UNREACHABLE
1530#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1531 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1533#if defined(JSON_HEDLEY_ASSUME)
1534 #undef JSON_HEDLEY_ASSUME
1537 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1538 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1539 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1540 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1541#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1542 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1544 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1545 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1546 #if defined(__cplusplus)
1547 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1549 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1553 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1554 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1555 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1556 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1557 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1558 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1559 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1560 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1561#elif defined(JSON_HEDLEY_ASSUME)
1562 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1564#if !defined(JSON_HEDLEY_ASSUME)
1565 #if defined(JSON_HEDLEY_UNREACHABLE)
1566 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1568 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1571#if defined(JSON_HEDLEY_UNREACHABLE)
1573 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1574 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1575 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1577 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1580 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1582#if !defined(JSON_HEDLEY_UNREACHABLE)
1583 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1587#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1588 #pragma clang diagnostic ignored "-Wpedantic"
1590#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1591 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1593#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1594 #if defined(__clang__)
1595 #pragma clang diagnostic ignored "-Wvariadic-macros"
1596 #elif defined(JSON_HEDLEY_GCC_VERSION)
1597 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1600#if defined(JSON_HEDLEY_NON_NULL)
1601 #undef JSON_HEDLEY_NON_NULL
1604 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1605 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1606 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1607 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1608 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1610 #define JSON_HEDLEY_NON_NULL(...)
1614#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1615 #undef JSON_HEDLEY_PRINTF_FORMAT
1617#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1618 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1619#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1620 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1622 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1623 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1624 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1625 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1626 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1627 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1628 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1629 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1630 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1631 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1632 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1633 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1634 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1635 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1636 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1637 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1638 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1639 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1640#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1641 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1643 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1646#if defined(JSON_HEDLEY_CONSTEXPR)
1647 #undef JSON_HEDLEY_CONSTEXPR
1649#if defined(__cplusplus)
1650 #if __cplusplus >= 201103L
1651 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1654#if !defined(JSON_HEDLEY_CONSTEXPR)
1655 #define JSON_HEDLEY_CONSTEXPR
1658#if defined(JSON_HEDLEY_PREDICT)
1659 #undef JSON_HEDLEY_PREDICT
1661#if defined(JSON_HEDLEY_LIKELY)
1662 #undef JSON_HEDLEY_LIKELY
1664#if defined(JSON_HEDLEY_UNLIKELY)
1665 #undef JSON_HEDLEY_UNLIKELY
1667#if defined(JSON_HEDLEY_UNPREDICTABLE)
1668 #undef JSON_HEDLEY_UNPREDICTABLE
1670#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1671 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1674 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1675 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1676 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1677# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1678# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1679# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1680# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1681# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1683 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1684 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1685 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1686 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1687 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1688 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1689 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1690 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1691 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1692 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1693 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1694 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1695 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1696 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1697 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1698 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1699# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1700 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1701# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1703 double hedley_probability_ = (probability); \
1704 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1706# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1708 double hedley_probability_ = (probability); \
1709 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1711# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1712# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1714# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1715# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1716# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1717# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1718# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1720#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1721 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1724#if defined(JSON_HEDLEY_MALLOC)
1725 #undef JSON_HEDLEY_MALLOC
1728 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1729 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1730 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1731 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1732 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1733 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1734 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1735 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1736 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1737 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1738 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1739 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1740 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1741 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1743 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1744 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1745 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1746 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1747#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1748 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1750 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1751 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1752 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1754 #define JSON_HEDLEY_MALLOC
1757#if defined(JSON_HEDLEY_PURE)
1758 #undef JSON_HEDLEY_PURE
1761 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1762 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1763 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1764 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1765 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1766 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1767 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1768 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1769 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1770 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1771 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1772 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1773 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1774 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1775 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1776 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1777 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1778 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1779 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1780# define JSON_HEDLEY_PURE __attribute__((__pure__))
1781#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1782# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1783#elif defined(__cplusplus) && \
1785 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1786 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1787 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1789# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1791# define JSON_HEDLEY_PURE
1794#if defined(JSON_HEDLEY_CONST)
1795 #undef JSON_HEDLEY_CONST
1798 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1799 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1800 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1801 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1802 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1803 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1804 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1805 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1806 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1807 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1808 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1809 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1810 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1811 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1812 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1813 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1814 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1815 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1816 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1817 #define JSON_HEDLEY_CONST __attribute__((__const__))
1819 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1820 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1822 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1825#if defined(JSON_HEDLEY_RESTRICT)
1826 #undef JSON_HEDLEY_RESTRICT
1828#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1829 #define JSON_HEDLEY_RESTRICT restrict
1831 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1832 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1833 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1834 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1835 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1836 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1837 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1838 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1839 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1840 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1841 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1842 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1843 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1844 defined(__clang__) || \
1845 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1846 #define JSON_HEDLEY_RESTRICT __restrict
1847#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1848 #define JSON_HEDLEY_RESTRICT _Restrict
1850 #define JSON_HEDLEY_RESTRICT
1853#if defined(JSON_HEDLEY_INLINE)
1854 #undef JSON_HEDLEY_INLINE
1857 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1858 (defined(__cplusplus) && (__cplusplus >= 199711L))
1859 #define JSON_HEDLEY_INLINE inline
1861 defined(JSON_HEDLEY_GCC_VERSION) || \
1862 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1863 #define JSON_HEDLEY_INLINE __inline__
1865 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1866 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1867 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1868 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1869 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1870 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1871 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1872 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1873 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1874 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1875 #define JSON_HEDLEY_INLINE __inline
1877 #define JSON_HEDLEY_INLINE
1880#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1881 #undef JSON_HEDLEY_ALWAYS_INLINE
1884 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1885 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1886 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1887 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1888 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1889 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1890 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1891 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1892 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1893 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1894 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1895 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1896 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1897 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1898 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1899 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1900 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1901 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1902 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1903# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1905 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1906 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1907# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1908#elif defined(__cplusplus) && \
1910 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1911 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1912 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1913 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1914 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1915 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1917# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1918#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1919# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1921# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1924#if defined(JSON_HEDLEY_NEVER_INLINE)
1925 #undef JSON_HEDLEY_NEVER_INLINE
1928 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1929 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1930 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1931 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1932 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1933 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1934 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1935 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1936 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1937 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1938 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1939 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1940 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1941 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1942 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1943 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1944 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1945 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1946 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1947 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1949 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1950 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1951 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1952#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1953 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1954#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1955 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1956#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1957 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1958#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1959 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1960#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1961 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1963 #define JSON_HEDLEY_NEVER_INLINE
1966#if defined(JSON_HEDLEY_PRIVATE)
1967 #undef JSON_HEDLEY_PRIVATE
1969#if defined(JSON_HEDLEY_PUBLIC)
1970 #undef JSON_HEDLEY_PUBLIC
1972#if defined(JSON_HEDLEY_IMPORT)
1973 #undef JSON_HEDLEY_IMPORT
1975#if defined(_WIN32) || defined(__CYGWIN__)
1976# define JSON_HEDLEY_PRIVATE
1977# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1978# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1981 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1982 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1983 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1984 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1985 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1986 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1988 defined(__TI_EABI__) && \
1990 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1991 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1994 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1995# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1996# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1998# define JSON_HEDLEY_PRIVATE
1999# define JSON_HEDLEY_PUBLIC
2001# define JSON_HEDLEY_IMPORT extern
2004#if defined(JSON_HEDLEY_NO_THROW)
2005 #undef JSON_HEDLEY_NO_THROW
2008 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2009 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2010 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2011 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2012 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2014 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2015 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2016 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2017 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2019 #define JSON_HEDLEY_NO_THROW
2022#if defined(JSON_HEDLEY_FALL_THROUGH)
2023 #undef JSON_HEDLEY_FALL_THROUGH
2026 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2027 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2028 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2029 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2030#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2031 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2032#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2033 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2034#elif defined(__fallthrough)
2035 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2037 #define JSON_HEDLEY_FALL_THROUGH
2040#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2041 #undef JSON_HEDLEY_RETURNS_NON_NULL
2044 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2045 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2046 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2047 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2048#elif defined(_Ret_notnull_)
2049 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2051 #define JSON_HEDLEY_RETURNS_NON_NULL
2054#if defined(JSON_HEDLEY_ARRAY_PARAM)
2055 #undef JSON_HEDLEY_ARRAY_PARAM
2058 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2059 !defined(__STDC_NO_VLA__) && \
2060 !defined(__cplusplus) && \
2061 !defined(JSON_HEDLEY_PGI_VERSION) && \
2062 !defined(JSON_HEDLEY_TINYC_VERSION)
2063 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2065 #define JSON_HEDLEY_ARRAY_PARAM(name)
2068#if defined(JSON_HEDLEY_IS_CONSTANT)
2069 #undef JSON_HEDLEY_IS_CONSTANT
2071#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2072 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2076#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2077 #undef JSON_HEDLEY_IS_CONSTEXPR_
2080 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2081 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2082 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2083 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2084 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2085 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2086 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2087 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2088 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2089 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2090 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2092#if !defined(__cplusplus)
2094 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2095 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2096 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2097 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2098 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2099 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2100 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2101#if defined(__INTPTR_TYPE__)
2102 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2105 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2109 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2110 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2111 !defined(JSON_HEDLEY_PGI_VERSION) && \
2112 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2113 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2114 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2115 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2116 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2117 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2118#if defined(__INTPTR_TYPE__)
2119 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2122 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2125 defined(JSON_HEDLEY_GCC_VERSION) || \
2126 defined(JSON_HEDLEY_INTEL_VERSION) || \
2127 defined(JSON_HEDLEY_TINYC_VERSION) || \
2128 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2129 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2130 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2131 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2132 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2133 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2135# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2139 ((void*) ((expr) * 0L) ) : \
2140((struct { char v[sizeof(void) * 2]; } *) 1) \
2146#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2147 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2148 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2150 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2152 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2153 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2155 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2158#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2159 #undef JSON_HEDLEY_BEGIN_C_DECLS
2161#if defined(JSON_HEDLEY_END_C_DECLS)
2162 #undef JSON_HEDLEY_END_C_DECLS
2164#if defined(JSON_HEDLEY_C_DECL)
2165 #undef JSON_HEDLEY_C_DECL
2167#if defined(__cplusplus)
2168 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2169 #define JSON_HEDLEY_END_C_DECLS }
2170 #define JSON_HEDLEY_C_DECL extern "C"
2172 #define JSON_HEDLEY_BEGIN_C_DECLS
2173 #define JSON_HEDLEY_END_C_DECLS
2174 #define JSON_HEDLEY_C_DECL
2177#if defined(JSON_HEDLEY_STATIC_ASSERT)
2178 #undef JSON_HEDLEY_STATIC_ASSERT
2181 !defined(__cplusplus) && ( \
2182 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2183 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2184 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2185 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2186 defined(_Static_assert) \
2188# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2190 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2191 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2192 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2193# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2195# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2198#if defined(JSON_HEDLEY_NULL)
2199 #undef JSON_HEDLEY_NULL
2201#if defined(__cplusplus)
2202 #if __cplusplus >= 201103L
2203 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2205 #define JSON_HEDLEY_NULL NULL
2207 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2210 #define JSON_HEDLEY_NULL NULL
2212 #define JSON_HEDLEY_NULL ((void*) 0)
2215#if defined(JSON_HEDLEY_MESSAGE)
2216 #undef JSON_HEDLEY_MESSAGE
2218#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2219# define JSON_HEDLEY_MESSAGE(msg) \
2220 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2221 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2222 JSON_HEDLEY_PRAGMA(message msg) \
2223 JSON_HEDLEY_DIAGNOSTIC_POP
2225 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2226 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2227# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2228#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2229# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2230#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2231# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2232#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2233# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2235# define JSON_HEDLEY_MESSAGE(msg)
2238#if defined(JSON_HEDLEY_WARNING)
2239 #undef JSON_HEDLEY_WARNING
2241#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2242# define JSON_HEDLEY_WARNING(msg) \
2243 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2244 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2245 JSON_HEDLEY_PRAGMA(clang warning msg) \
2246 JSON_HEDLEY_DIAGNOSTIC_POP
2248 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2249 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2250 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2251# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2253 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2254 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2255# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2257# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2260#if defined(JSON_HEDLEY_REQUIRE)
2261 #undef JSON_HEDLEY_REQUIRE
2263#if defined(JSON_HEDLEY_REQUIRE_MSG)
2264 #undef JSON_HEDLEY_REQUIRE_MSG
2266#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2267# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2268# define JSON_HEDLEY_REQUIRE(expr) \
2269 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2270 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2271 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2272 JSON_HEDLEY_DIAGNOSTIC_POP
2273# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2274 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2275 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2276 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2277 JSON_HEDLEY_DIAGNOSTIC_POP
2279# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2283# define JSON_HEDLEY_REQUIRE(expr)
2284# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2287#if defined(JSON_HEDLEY_FLAGS)
2288 #undef JSON_HEDLEY_FLAGS
2290#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2291 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2293 #define JSON_HEDLEY_FLAGS
2296#if defined(JSON_HEDLEY_FLAGS_CAST)
2297 #undef JSON_HEDLEY_FLAGS_CAST
2299#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2300# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2301 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2302 _Pragma("warning(disable:188)") \
2304 JSON_HEDLEY_DIAGNOSTIC_POP \
2307# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2310#if defined(JSON_HEDLEY_EMPTY_BASES)
2311 #undef JSON_HEDLEY_EMPTY_BASES
2314 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2315 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2316 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2318 #define JSON_HEDLEY_EMPTY_BASES
2323#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2324 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2326#if defined(__clang__)
2327 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2329 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2332#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2333 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2335#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2337#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2338 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2340#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2342#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2343 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2345#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2347#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2348 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2350#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2352#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2353 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2355#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2357#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2358 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2360#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2362#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2363 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2365#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2377#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2378 #if defined(__clang__)
2379 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2380 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2382 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2383 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2384 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2391#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2392 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2393 #define JSON_HAS_CPP_20
2394 #define JSON_HAS_CPP_17
2395 #define JSON_HAS_CPP_14
2396 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2397 #define JSON_HAS_CPP_17
2398 #define JSON_HAS_CPP_14
2399 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2400 #define JSON_HAS_CPP_14
2403 #define JSON_HAS_CPP_11
2407 #if __has_include(<version>)
2412#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2413 #ifdef JSON_HAS_CPP_17
2414 #if defined(__cpp_lib_filesystem)
2415 #define JSON_HAS_FILESYSTEM 1
2416 #elif defined(__cpp_lib_experimental_filesystem)
2417 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2418 #elif !defined(__has_include)
2419 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2420 #elif __has_include(<filesystem>)
2421 #define JSON_HAS_FILESYSTEM 1
2422 #elif __has_include(<experimental/filesystem>)
2423 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2427 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2428 #undef JSON_HAS_FILESYSTEM
2429 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2433 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2434 #undef JSON_HAS_FILESYSTEM
2435 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2439 #if defined(__clang_major__) && __clang_major__ < 7
2440 #undef JSON_HAS_FILESYSTEM
2441 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2445 #if defined(_MSC_VER) && _MSC_VER < 1914
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2457 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2458 #undef JSON_HAS_FILESYSTEM
2459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2464#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2465 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2468#ifndef JSON_HAS_FILESYSTEM
2469 #define JSON_HAS_FILESYSTEM 0
2472#ifndef JSON_HAS_THREE_WAY_COMPARISON
2473 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2474 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2475 #define JSON_HAS_THREE_WAY_COMPARISON 1
2477 #define JSON_HAS_THREE_WAY_COMPARISON 0
2481#ifndef JSON_HAS_RANGES
2483 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2484 #define JSON_HAS_RANGES 0
2485 #elif defined(__cpp_lib_ranges)
2486 #define JSON_HAS_RANGES 1
2488 #define JSON_HAS_RANGES 0
2492#ifndef JSON_HAS_STATIC_RTTI
2493 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2494 #define JSON_HAS_STATIC_RTTI 1
2496 #define JSON_HAS_STATIC_RTTI 0
2500#ifdef JSON_HAS_CPP_17
2501 #define JSON_INLINE_VARIABLE inline
2503 #define JSON_INLINE_VARIABLE
2506#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2507 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2509 #define JSON_NO_UNIQUE_ADDRESS
2513#if defined(__clang__)
2514 #pragma clang diagnostic push
2515 #pragma clang diagnostic ignored "-Wdocumentation"
2516 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2520#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2521 #define JSON_THROW(exception) throw exception
2522 #define JSON_TRY try
2523 #define JSON_CATCH(exception) catch(exception)
2524 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2527 #define JSON_THROW(exception) std::abort()
2528 #define JSON_TRY if(true)
2529 #define JSON_CATCH(exception) if(false)
2530 #define JSON_INTERNAL_CATCH(exception) if(false)
2534#if defined(JSON_THROW_USER)
2536 #define JSON_THROW JSON_THROW_USER
2538#if defined(JSON_TRY_USER)
2540 #define JSON_TRY JSON_TRY_USER
2542#if defined(JSON_CATCH_USER)
2544 #define JSON_CATCH JSON_CATCH_USER
2545 #undef JSON_INTERNAL_CATCH
2546 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2548#if defined(JSON_INTERNAL_CATCH_USER)
2549 #undef JSON_INTERNAL_CATCH
2550 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2554#if !defined(JSON_ASSERT)
2556 #define JSON_ASSERT(x) assert(x)
2560#if defined(JSON_TESTS_PRIVATE)
2561 #define JSON_PRIVATE_UNLESS_TESTED public
2563 #define JSON_PRIVATE_UNLESS_TESTED private
2571#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2572 template<typename BasicJsonType> \
2573 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2576 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2578 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2579 auto it = std::find_if(std::begin(m), std::end(m), \
2580 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2582 return ej_pair.first == e; \
2584 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2586 template<typename BasicJsonType> \
2587 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2590 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2592 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2593 auto it = std::find_if(std::begin(m), std::end(m), \
2594 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2596 return ej_pair.second == j; \
2598 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2604#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2605 template<template<typename, typename, typename...> class ObjectType, \
2606 template<typename, typename...> class ArrayType, \
2607 class StringType, class BooleanType, class NumberIntegerType, \
2608 class NumberUnsignedType, class NumberFloatType, \
2609 template<typename> class AllocatorType, \
2610 template<typename, typename = void> class JSONSerializer, \
2612 class CustomBaseClass>
2614#define NLOHMANN_BASIC_JSON_TPL \
2615 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2616 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2617 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2621#define NLOHMANN_JSON_EXPAND( x ) x
2622#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2623#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2624 NLOHMANN_JSON_PASTE64, \
2625 NLOHMANN_JSON_PASTE63, \
2626 NLOHMANN_JSON_PASTE62, \
2627 NLOHMANN_JSON_PASTE61, \
2628 NLOHMANN_JSON_PASTE60, \
2629 NLOHMANN_JSON_PASTE59, \
2630 NLOHMANN_JSON_PASTE58, \
2631 NLOHMANN_JSON_PASTE57, \
2632 NLOHMANN_JSON_PASTE56, \
2633 NLOHMANN_JSON_PASTE55, \
2634 NLOHMANN_JSON_PASTE54, \
2635 NLOHMANN_JSON_PASTE53, \
2636 NLOHMANN_JSON_PASTE52, \
2637 NLOHMANN_JSON_PASTE51, \
2638 NLOHMANN_JSON_PASTE50, \
2639 NLOHMANN_JSON_PASTE49, \
2640 NLOHMANN_JSON_PASTE48, \
2641 NLOHMANN_JSON_PASTE47, \
2642 NLOHMANN_JSON_PASTE46, \
2643 NLOHMANN_JSON_PASTE45, \
2644 NLOHMANN_JSON_PASTE44, \
2645 NLOHMANN_JSON_PASTE43, \
2646 NLOHMANN_JSON_PASTE42, \
2647 NLOHMANN_JSON_PASTE41, \
2648 NLOHMANN_JSON_PASTE40, \
2649 NLOHMANN_JSON_PASTE39, \
2650 NLOHMANN_JSON_PASTE38, \
2651 NLOHMANN_JSON_PASTE37, \
2652 NLOHMANN_JSON_PASTE36, \
2653 NLOHMANN_JSON_PASTE35, \
2654 NLOHMANN_JSON_PASTE34, \
2655 NLOHMANN_JSON_PASTE33, \
2656 NLOHMANN_JSON_PASTE32, \
2657 NLOHMANN_JSON_PASTE31, \
2658 NLOHMANN_JSON_PASTE30, \
2659 NLOHMANN_JSON_PASTE29, \
2660 NLOHMANN_JSON_PASTE28, \
2661 NLOHMANN_JSON_PASTE27, \
2662 NLOHMANN_JSON_PASTE26, \
2663 NLOHMANN_JSON_PASTE25, \
2664 NLOHMANN_JSON_PASTE24, \
2665 NLOHMANN_JSON_PASTE23, \
2666 NLOHMANN_JSON_PASTE22, \
2667 NLOHMANN_JSON_PASTE21, \
2668 NLOHMANN_JSON_PASTE20, \
2669 NLOHMANN_JSON_PASTE19, \
2670 NLOHMANN_JSON_PASTE18, \
2671 NLOHMANN_JSON_PASTE17, \
2672 NLOHMANN_JSON_PASTE16, \
2673 NLOHMANN_JSON_PASTE15, \
2674 NLOHMANN_JSON_PASTE14, \
2675 NLOHMANN_JSON_PASTE13, \
2676 NLOHMANN_JSON_PASTE12, \
2677 NLOHMANN_JSON_PASTE11, \
2678 NLOHMANN_JSON_PASTE10, \
2679 NLOHMANN_JSON_PASTE9, \
2680 NLOHMANN_JSON_PASTE8, \
2681 NLOHMANN_JSON_PASTE7, \
2682 NLOHMANN_JSON_PASTE6, \
2683 NLOHMANN_JSON_PASTE5, \
2684 NLOHMANN_JSON_PASTE4, \
2685 NLOHMANN_JSON_PASTE3, \
2686 NLOHMANN_JSON_PASTE2, \
2687 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2688#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2689#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2690#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2691#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2692#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2693#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2694#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2695#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2696#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2697#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2698#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2699#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2700#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2701#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2702#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2703#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2704#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2705#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2706#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2707#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2708#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2709#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2710#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2711#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2712#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2713#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2714#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2715#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2716#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2717#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2718#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2719#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2720#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2721#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2722#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2723#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2724#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2725#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2726#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2727#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2728#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2729#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2730#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2731#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2732#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2733#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2734#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2735#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2736#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2737#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2738#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2739#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2740#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2741#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2742#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2743#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2744#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2745#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2746#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2747#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2748#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2749#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2750#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2752#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2753#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2754#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2761#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2762 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2763 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2765#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2766 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2767 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2769#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2770 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2777#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2778 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2779 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2781#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2782 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2784#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2785 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2786 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2793#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2794 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2795 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2797#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2798 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2799 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2806#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2807 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2808 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2810#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2811 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2812 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2820#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2821 namespace detail { \
2822 using std::std_name; \
2824 template<typename... T> \
2825 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2828 namespace detail2 { \
2829 struct std_name##_tag \
2833 template<typename... T> \
2834 std_name##_tag std_name(T&&...); \
2836 template<typename... T> \
2837 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2839 template<typename... T> \
2840 struct would_call_std_##std_name \
2842 static constexpr auto const value = ::nlohmann::detail:: \
2843 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2847 template<typename... T> \
2848 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2852#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2853 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2856#if JSON_USE_IMPLICIT_CONVERSIONS
2857 #define JSON_EXPLICIT
2859 #define JSON_EXPLICIT explicit
2862#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2863 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2866#ifndef JSON_USE_GLOBAL_UDLS
2867 #define JSON_USE_GLOBAL_UDLS 1
2870#if JSON_HAS_THREE_WAY_COMPARISON
2933#if JSON_HAS_THREE_WAY_COMPARISON
2934 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2939 static constexpr std::array<std::uint8_t, 9> order = {{
2946 const auto l_index =
static_cast<std::size_t
>(lhs);
2947 const auto r_index =
static_cast<std::size_t
>(rhs);
2948#if JSON_HAS_THREE_WAY_COMPARISON
2949 if (l_index < order.size() && r_index < order.size())
2951 return order[l_index] <=> order[r_index];
2953 return std::partial_ordering::unordered;
2955 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2963#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2966 return std::is_lt(lhs <=> rhs);
3004template<
typename StringType>
3006 const StringType& t)
3009 for (
auto pos = s.find(
f);
3010 pos != StringType::npos;
3011 s.replace(pos,
f.size(), t),
3012 pos = s.find(
f, pos + t.size()))
3023template<
typename StringType>
3038template<
typename StringType>
3039static void unescape(StringType& s)
3079 constexpr operator size_t()
const
3104#include <type_traits>
3117#ifdef JSON_HAS_CPP_14
3120using std::enable_if_t;
3121using std::index_sequence;
3122using std::make_index_sequence;
3123using std::index_sequence_for;
3128template<
bool B,
typename T =
void>
3155template <
typename T, T... Ints>
3159 static constexpr std::size_t
size() noexcept
3161 return sizeof...(Ints);
3170template <
size_t... Ints>
3173namespace utility_internal
3176template <
typename Seq,
size_t SeqSize,
size_t Rem>
3180template <
typename T, T... Ints,
size_t SeqSize>
3186template <
typename T, T... Ints,
size_t SeqSize>
3194template <
typename T,
size_t N>
3201template <
typename T>
3216template <
typename T, T N>
3232template <
typename... Ts>
3250#ifndef JSON_HAS_CPP_17
3251 template<
typename T>
3255template<
typename T,
typename... Args>
3256constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3258 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3276#include <type_traits>
3305template<
typename It,
typename =
void>
3308template<
typename It>
3312 typename It::reference, typename It::iterator_category >>
3323template<
typename T,
typename =
void>
3402#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3403 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3428 template<
typename T =
void,
typename SFINAE =
void>
3433 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3435 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3436 class StringType = std::string,
class BooleanType = bool,
3437 class NumberIntegerType = std::int64_t,
3438 class NumberUnsignedType = std::uint64_t,
3439 class NumberFloatType = double,
3440 template<
typename U>
class AllocatorType = std::allocator,
3441 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3443 class BinaryType = std::vector<std::uint8_t>,
3444 class CustomBaseClass =
void>
3449 template<
typename RefStringType>
3460 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3505template<
typename BasicJsonContext>
3507 std::integral_constant < bool,
3508 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3509 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3550template<
typename T,
typename... Args>
3553template<
typename T,
typename... Args>
3556template<
typename T,
typename U>
3560template<
typename BasicJsonType,
typename T,
typename =
void>
3567template <
typename BasicJsonType,
typename T>
3573template<
typename BasicJsonType,
typename T>
3576 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3580 const BasicJsonType&, T&>
::value;
3585template<
typename BasicJsonType,
typename T,
typename =
void>
3588template<
typename BasicJsonType,
typename T>
3591 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3600template<
typename BasicJsonType,
typename T,
typename =
void>
3603template<
typename BasicJsonType,
typename T>
3606 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3617struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3620template<
typename BasicJsonType>
3625 using type =
typename std::conditional < has_key_compare<object_t>::value,
3629template<
typename BasicJsonType>
3696template<
class B,
class... Bn>
3698: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>
::type {};
3701template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3706template <
typename T>
3709template <
typename T1,
typename T2>
3711 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3713template <
typename T1,
typename T2>
3715 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3717template <
typename... Ts>
3719 :
conjunction<is_default_constructible<Ts>...> {};
3721template <
typename... Ts>
3723 :
conjunction<is_default_constructible<Ts>...> {};
3725template <
typename T,
typename... Args>
3728template <
typename T1,
typename T2>
3731template <
typename T1,
typename T2>
3734template <
typename... Ts>
3737template <
typename... Ts>
3740template<
typename T,
typename =
void>
3762 using t_ref =
typename std::add_lvalue_reference<T>::type;
3770 static constexpr auto is_iterator_begin =
3774 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3787template<
typename T,
typename =
void>
3793template<
typename BasicJsonType,
typename CompatibleObjectType,
3797template<
typename BasicJsonType,
typename CompatibleObjectType>
3799 BasicJsonType, CompatibleObjectType,
3808 typename CompatibleObjectType::key_type>
::value &&
3810 typename CompatibleObjectType::mapped_type>
::value;
3813template<
typename BasicJsonType,
typename CompatibleObjectType>
3817template<
typename BasicJsonType,
typename ConstructibleObjectType,
3821template<
typename BasicJsonType,
typename ConstructibleObjectType>
3823 BasicJsonType, ConstructibleObjectType,
3831 (std::is_move_assignable<ConstructibleObjectType>::value ||
3832 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3834 typename object_t::key_type>
::value &&
3836 typename object_t::mapped_type,
3837 typename ConstructibleObjectType::mapped_type >
::value)) ||
3839 typename ConstructibleObjectType::mapped_type>
::value ||
3842 typename ConstructibleObjectType::mapped_type >
::value);
3845template<
typename BasicJsonType,
typename ConstructibleObjectType>
3848 ConstructibleObjectType> {};
3850template<
typename BasicJsonType,
typename CompatibleStringType>
3857template<
typename BasicJsonType,
typename ConstructibleStringType>
3861#ifdef __INTEL_COMPILER
3862 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3874template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3877template<
typename BasicJsonType,
typename CompatibleArrayType>
3879 BasicJsonType, CompatibleArrayType,
3885 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3892template<
typename BasicJsonType,
typename CompatibleArrayType>
3896template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3899template<
typename BasicJsonType,
typename ConstructibleArrayType>
3901 BasicJsonType, ConstructibleArrayType,
3903 typename BasicJsonType::value_type>
::value >>
3904 : std::true_type {};
3906template<
typename BasicJsonType,
typename ConstructibleArrayType>
3908 BasicJsonType, ConstructibleArrayType,
3910 typename BasicJsonType::value_type>
::value&&
3913(std::is_move_assignable<ConstructibleArrayType>::value ||
3914 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3920!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3922 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3928 typename BasicJsonType::array_t::value_type>
::value ||
3936template<
typename BasicJsonType,
typename ConstructibleArrayType>
3940template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3944template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3946 RealIntegerType, CompatibleNumberIntegerType,
3948 std::is_integral<CompatibleNumberIntegerType>
::value&&
3949 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3957 CompatibleNumberIntegerType>
::value &&
3958 CompatibleLimits::is_integer &&
3959 RealLimits::is_signed == CompatibleLimits::is_signed;
3962template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3965 CompatibleNumberIntegerType> {};
3967template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3970template<
typename BasicJsonType,
typename CompatibleType>
3972 BasicJsonType, CompatibleType,
3979template<
typename BasicJsonType,
typename CompatibleType>
3983template<
typename T1,
typename T2>
3986template<
typename T1,
typename... Args>
3989template<
typename BasicJsonType,
typename T>
3992template<
typename BasicJsonType>
3995template<
typename BasicJsonType>
4000template<
template <
typename...>
class Primary,
typename T>
4003template<
template <
typename...>
class Primary,
typename... Args>
4010template<
typename Compare,
typename A,
typename B,
typename =
void>
4013template<
typename Compare,
typename A,
typename B>
4015decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4016decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4017>> : std::true_type {};
4024template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4028 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4030 && (!RequireTransparentComparator
4031 || is_detected <detect_is_transparent, Comparator>::value)
4042template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4046 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4047 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4052template<
typename ObjectType,
typename KeyType>
4056template<
typename BasicJsonType,
typename KeyType>
4060 typename BasicJsonType::object_t, KeyType >
::value,
4066template <
typename T>
4076 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4079 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
4083template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4086 return static_cast<T
>(
value);
4089template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4095template<
typename... Types>
4098template<
typename... Types>
4101template<
typename... Types>
4105template<
typename... Types>
4109template<
typename OfType,
typename T>
4111 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4114template<
typename OfType,
typename T,
4115 bool OfTypeSigned = std::is_signed<OfType>::value,
4116 bool TSigned = std::is_signed<T>::value>
4119template<
typename OfType,
typename T>
4124 using CommonType =
typename std::common_type<OfType, T>::type;
4125 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4129template<
typename OfType,
typename T>
4134 using CommonType =
typename std::common_type<OfType, T>::type;
4135 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4139template<
typename OfType,
typename T>
4144 using CommonType =
typename std::common_type<OfType, T>::type;
4145 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4149template<
typename OfType,
typename T>
4154 using CommonType =
typename std::common_type<OfType, T>::type;
4155 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4156 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4160template<
typename OfType,
typename T,
4161 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4165template<
typename OfType,
typename T>
4174template<
typename OfType,
typename T>
4183template<
typename OfType,
typename T>
4202 using TUnExt =
typename std::remove_extent<T>::type;
4203 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4204 using TUnPtr =
typename std::remove_pointer<T>::type;
4205 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4207 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4208 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4273template<
typename... Args>
4274inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4276template<
typename StringType,
typename... Args>
4277inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4279template<
typename... Args>
4285template<
typename... Args>
4292template<
typename StringType,
typename... Args>
4298template<
typename OutStringType>
4302template<
typename StringType,
typename Arg>
4305template<
typename StringType,
typename Arg>
4308template<
typename StringType,
typename Arg>
4311template<
typename StringType,
typename Arg>
4314template<
typename StringType,
typename Arg>
4315using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().
end()));
4317template<
typename StringType,
typename Arg>
4320template<
typename StringType,
typename Arg>
4323template<
typename StringType,
typename Arg>
4326template <
typename OutStringType,
typename Arg,
typename... Args,
4327 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4329inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4331template <
typename OutStringType,
typename Arg,
typename... Args,
4332 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4335inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4337template <
typename OutStringType,
typename Arg,
typename... Args,
4338 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4342inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4344template<
typename OutStringType,
typename Arg,
typename... Args,
4346inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4348 out.append(std::forward<Arg>(arg));
4352template <
typename OutStringType,
typename Arg,
typename... Args,
4353 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4354 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4355inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4357 out += std::forward<Arg>(arg);
4361template <
typename OutStringType,
typename Arg,
typename... Args,
4362 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4363 && !detect_string_can_append_op<OutStringType, Arg>::value
4364 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4365inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4367 out.append(arg.begin(), arg.end());
4371template <
typename OutStringType,
typename Arg,
typename... Args,
4372 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4373 && !detect_string_can_append_op<OutStringType, Arg>::value
4374 && !detect_string_can_append_iter<OutStringType, Arg>::value
4375 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4376inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4378 out.append(arg.data(), arg.size());
4382template<
typename OutStringType = std::string,
typename... Args>
4402#if defined(__clang__)
4403 #pragma clang diagnostic push
4404 #pragma clang diagnostic ignored "-Wweak-vtables"
4421 const char*
what() const noexcept
override
4431 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4433 static std::string
name(
const std::string& ename,
int id_)
4435 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4443 template<
typename BasicJsonType>
4447 std::vector<std::string> tokens;
4448 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4450 switch (current->m_parent->type())
4454 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4456 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4458 tokens.emplace_back(std::to_string(i));
4467 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4469 if (&element.second == current)
4471 tokens.emplace_back(element.first.c_str());
4496 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4497 [](
const std::string &
a,
const std::string &
b)
4499 return concat(a,
'/', detail::escape(b));
4501 return concat(
'(', str,
") ");
4503 static_cast<void>(leaf_element);
4510 std::runtime_error m;
4527 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4535 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4536 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4539 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4541 return {id_, byte_,
w.c_str()};
4556 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4559 static std::string position_string(
const position_t& pos)
4571 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4575 return {id_,
w.c_str()};
4589 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4593 return {id_,
w.c_str()};
4606 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4610 return {id_,
w.c_str()};
4623 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4627 return {id_,
w.c_str()};
4638#if defined(__clang__)
4639 #pragma clang diagnostic pop
4665template <
class T>
struct identity_tag {};
4684#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4685#include <experimental/filesystem>
4689namespace std_fs = std::experimental::filesystem;
4692#elif JSON_HAS_FILESYSTEM
4693#include <filesystem>
4697namespace std_fs = std::filesystem;
4713template<
typename BasicJsonType>
4714inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4723#ifdef JSON_HAS_CPP_17
4724#ifndef JSON_USE_IMPLICIT_CONVERSIONS
4725template<
typename BasicJsonType,
typename T>
4726void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4734 opt.emplace(j.template get<T>());
4742template <
typename BasicJsonType,
typename ArithmeticType,
4743 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4744 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4746void get_arithmetic_value(
const BasicJsonType& j, ArithmeticType& val)
4748 switch (
static_cast<value_t>(j))
4752 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4757 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4762 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4778template<
typename BasicJsonType>
4779inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t&
b)
4785 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4788template<
typename BasicJsonType>
4789inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4795 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4799 typename BasicJsonType,
typename StringType,
4801 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4802 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4803 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4804 && !is_json_ref<StringType>::value,
int > = 0 >
4805inline void from_json(
const BasicJsonType& j, StringType& s)
4812 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4815template<
typename BasicJsonType>
4816inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4818 get_arithmetic_value(j, val);
4821template<
typename BasicJsonType>
4822inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4824 get_arithmetic_value(j, val);
4827template<
typename BasicJsonType>
4828inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4830 get_arithmetic_value(j, val);
4833#if !JSON_DISABLE_ENUM_SERIALIZATION
4834template<
typename BasicJsonType,
typename EnumType,
4835 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4836inline void from_json(
const BasicJsonType& j, EnumType& e)
4838 typename std::underlying_type<EnumType>::type val;
4839 get_arithmetic_value(j, val);
4840 e =
static_cast<EnumType
>(val);
4845template<
typename BasicJsonType,
typename T,
typename Allocator,
4846 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4847inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4854 std::transform(j.rbegin(), j.rend(),
4855 std::front_inserter(l), [](
const BasicJsonType & i)
4857 return i.template get<T>();
4862template<
typename BasicJsonType,
typename T,
4863 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4864inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4871 std::transform(j.begin(), j.end(), std::begin(l),
4872 [](
const BasicJsonType & elem)
4874 return elem.template get<T>();
4878template<
typename BasicJsonType,
typename T, std::
size_t N>
4879auto from_json(
const BasicJsonType& j, T (&arr)[N])
4880->
decltype(j.template get<T>(),
void())
4882 for (std::size_t i = 0; i < N; ++i)
4884 arr[i] = j.at(i).template get<T>();
4888template<
typename BasicJsonType>
4889inline void from_json_array_impl(
const BasicJsonType& j,
typename BasicJsonType::array_t& arr, priority_tag<3> )
4891 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4894template<
typename BasicJsonType,
typename T, std::
size_t N>
4895auto from_json_array_impl(
const BasicJsonType& j, std::array<T, N>& arr,
4897->
decltype(j.template get<T>(),
void())
4899 for (std::size_t i = 0; i < N; ++i)
4901 arr[i] = j.at(i).template get<T>();
4905template<
typename BasicJsonType,
typename ConstructibleArrayType,
4907 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4909auto from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> )
4911 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4912 j.template get<typename ConstructibleArrayType::value_type>(),
4917 ConstructibleArrayType ret;
4918 ret.reserve(j.size());
4919 std::transform(j.begin(), j.end(),
4920 std::inserter(ret,
end(ret)), [](
const BasicJsonType & i)
4924 return i.template get<typename ConstructibleArrayType::value_type>();
4926 arr = std::move(ret);
4929template<
typename BasicJsonType,
typename ConstructibleArrayType,
4931 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4933inline void from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr,
4938 ConstructibleArrayType ret;
4940 j.begin(), j.end(), std::inserter(ret,
end(ret)),
4941 [](
const BasicJsonType & i)
4945 return i.template get<typename ConstructibleArrayType::value_type>();
4947 arr = std::move(ret);
4950template <
typename BasicJsonType,
typename ConstructibleArrayType,
4952 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4953 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4955 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4956 !is_basic_json<ConstructibleArrayType>::value,
4958auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4959->
decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
4960j.template get<typename ConstructibleArrayType::value_type>(),
4968 from_json_array_impl(j, arr, priority_tag<3> {});
4971template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4972std::array<T,
sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
4973 identity_tag<std::array<T,
sizeof...(Idx)>> ,
index_sequence<Idx...> )
4975 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4978template <
typename BasicJsonType,
typename T, std::
size_t N >
4979auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4980->
decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
4987 return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
4990template<
typename BasicJsonType>
4991inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4998 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5001template<
typename BasicJsonType,
typename ConstructibleObjectType,
5002 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5003inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5010 ConstructibleObjectType ret;
5011 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5012 using value_type =
typename ConstructibleObjectType::value_type;
5014 inner_object->begin(), inner_object->end(),
5015 std::inserter(ret, ret.begin()),
5016 [](
typename BasicJsonType::object_t::value_type
const & p)
5018 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5020 obj = std::move(ret);
5027template <
typename BasicJsonType,
typename ArithmeticType,
5029 std::is_arithmetic<ArithmeticType>::value&&
5030 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5031 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5032 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5033 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5035inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5037 switch (
static_cast<value_t>(j))
5041 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5046 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5051 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5056 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5071template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5072std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> )
5074 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5077template <
typename BasicJsonType,
class A1,
class A2 >
5078std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> , priority_tag<0> )
5080 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
5081 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
5084template<
typename BasicJsonType,
typename A1,
typename A2>
5085inline void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> )
5087 p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
5090template<
typename BasicJsonType,
typename... Args>
5091std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> , priority_tag<2> )
5093 return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
index_sequence_for<Args...> {});
5096template<
typename BasicJsonType,
typename... Args>
5097inline void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> )
5099 t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j),
index_sequence_for<Args...> {});
5102template<
typename BasicJsonType,
typename TupleRelated>
5103auto from_json(BasicJsonType&& j, TupleRelated&& t)
5104->
decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
5111 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5114template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5116 typename BasicJsonType::string_t, Key >
::value >>
5117inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5124 for (
const auto& p : j)
5130 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5134template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5136 typename BasicJsonType::string_t, Key >
::value >>
5137inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5144 for (
const auto& p : j)
5150 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5154#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5155template<
typename BasicJsonType>
5156inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5162 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5168 template<
typename BasicJsonType,
typename T>
5169 auto operator()(
const BasicJsonType& j, T&& val)
const
5170 noexcept(
noexcept(from_json(j, std::forward<T>(val))))
5171 ->
decltype(from_json(j, std::forward<T>(val)))
5173 return from_json(j, std::forward<T>(val));
5179#ifndef JSON_HAS_CPP_17
5188#ifndef JSON_HAS_CPP_17
5207#ifdef JSON_HAS_CPP_17
5212#include <type_traits>
5249template<
typename string_type>
5253 using std::to_string;
5268 IteratorType anchor{};
5270 std::size_t array_index = 0;
5272 mutable std::size_t array_index_last = 0;
5281 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5283 : anchor(
std::move(it))
5284 , array_index(array_index_)
5291 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5294 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5324 return anchor == o.anchor;
5330 return anchor != o.anchor;
5338 switch (anchor.m_object->type())
5343 if (array_index != array_index_last)
5346 array_index_last = array_index;
5348 return array_index_str;
5353 return anchor.key();
5370 typename IteratorType::reference
value()
const
5372 return anchor.value();
5381 typename IteratorType::pointer container =
nullptr;
5388 : container(&cont) {}
5412template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5413auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5420template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5421auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5436#if defined(__clang__)
5438 #pragma clang diagnostic push
5439 #pragma clang diagnostic ignored "-Wmismatched-tags"
5441template<
typename IteratorType>
5442class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5443 :
public std::integral_constant<std::size_t, 2> {};
5445template<std::
size_t N,
typename IteratorType>
5446class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5450 get<N>(std::declval <
5451 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5453#if defined(__clang__)
5454 #pragma clang diagnostic pop
5460 template <
typename IteratorType>
5461 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5495 template<
typename BasicJsonType>
5496 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t
b)
noexcept
5498 j.m_data.m_value.destroy(j.m_data.m_type);
5500 j.m_data.m_value =
b;
5501 j.assert_invariant();
5508 template<
typename BasicJsonType>
5509 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5511 j.m_data.m_value.destroy(j.m_data.m_type);
5513 j.m_data.m_value = s;
5514 j.assert_invariant();
5517 template<
typename BasicJsonType>
5518 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5520 j.m_data.m_value.destroy(j.m_data.m_type);
5522 j.m_data.m_value = std::move(s);
5523 j.assert_invariant();
5526 template <
typename BasicJsonType,
typename CompatibleStringType,
5527 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5529 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5531 j.m_data.m_value.destroy(j.m_data.m_type);
5533 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5534 j.assert_invariant();
5541 template<
typename BasicJsonType>
5542 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t&
b)
5544 j.m_data.m_value.destroy(j.m_data.m_type);
5546 j.m_data.m_value =
typename BasicJsonType::binary_t(
b);
5547 j.assert_invariant();
5550 template<
typename BasicJsonType>
5551 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&&
b)
5553 j.m_data.m_value.destroy(j.m_data.m_type);
5555 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(
b));
5556 j.assert_invariant();
5563 template<
typename BasicJsonType>
5564 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5566 j.m_data.m_value.destroy(j.m_data.m_type);
5568 j.m_data.m_value = val;
5569 j.assert_invariant();
5576 template<
typename BasicJsonType>
5577 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5579 j.m_data.m_value.destroy(j.m_data.m_type);
5581 j.m_data.m_value = val;
5582 j.assert_invariant();
5589 template<
typename BasicJsonType>
5590 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5592 j.m_data.m_value.destroy(j.m_data.m_type);
5594 j.m_data.m_value = val;
5595 j.assert_invariant();
5602 template<
typename BasicJsonType>
5603 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5605 j.m_data.m_value.destroy(j.m_data.m_type);
5607 j.m_data.m_value = arr;
5609 j.assert_invariant();
5612 template<
typename BasicJsonType>
5613 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5615 j.m_data.m_value.destroy(j.m_data.m_type);
5617 j.m_data.m_value = std::move(arr);
5619 j.assert_invariant();
5622 template <
typename BasicJsonType,
typename CompatibleArrayType,
5623 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5625 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5630 j.m_data.m_value.destroy(j.m_data.m_type);
5632 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr),
end(arr));
5634 j.assert_invariant();
5637 template<
typename BasicJsonType>
5638 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5640 j.m_data.m_value.destroy(j.m_data.m_type);
5643 j.m_data.m_value.array->reserve(arr.size());
5644 for (
const bool x : arr)
5646 j.m_data.m_value.array->push_back(
x);
5647 j.set_parent(j.m_data.m_value.array->back());
5649 j.assert_invariant();
5652 template<
typename BasicJsonType,
typename T,
5654 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5656 j.m_data.m_value.destroy(j.m_data.m_type);
5659 j.m_data.m_value.array->resize(arr.size());
5662 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5665 j.assert_invariant();
5672 template<
typename BasicJsonType>
5673 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5675 j.m_data.m_value.destroy(j.m_data.m_type);
5677 j.m_data.m_value = obj;
5679 j.assert_invariant();
5682 template<
typename BasicJsonType>
5683 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5685 j.m_data.m_value.destroy(j.m_data.m_type);
5687 j.m_data.m_value = std::move(obj);
5689 j.assert_invariant();
5692 template <
typename BasicJsonType,
typename CompatibleObjectType,
5693 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5694 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5699 j.m_data.m_value.destroy(j.m_data.m_type);
5701 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj),
end(obj));
5703 j.assert_invariant();
5711#ifdef JSON_HAS_CPP_17
5712template<
typename BasicJsonType,
typename T,
5713 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5714void to_json(BasicJsonType& j,
const std::optional<T>& opt)
5716 if (opt.has_value())
5727template<
typename BasicJsonType,
typename T,
5728 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5734template <
typename BasicJsonType,
typename BoolRef,
5736 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5737 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5738 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5740 typename BasicJsonType::boolean_t >
::value))
5741 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5742inline void to_json(BasicJsonType& j,
const BoolRef&
b)
noexcept
5747template<
typename BasicJsonType,
typename CompatibleString,
5748 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5749inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5754template<
typename BasicJsonType>
5755inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5760template<
typename BasicJsonType,
typename FloatType,
5761 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5762inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5767template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5768 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5769inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5774template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5775 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5776inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5781#if !JSON_DISABLE_ENUM_SERIALIZATION
5782template<
typename BasicJsonType,
typename EnumType,
5783 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5784inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5786 using underlying_type =
typename std::underlying_type<EnumType>::type;
5792template<
typename BasicJsonType>
5793inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5798template <
typename BasicJsonType,
typename CompatibleArrayType,
5799 enable_if_t < is_compatible_array_type<BasicJsonType,
5801 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5803 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5804 !is_basic_json<CompatibleArrayType>::value,
5806inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5811template<
typename BasicJsonType>
5812inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5817template<
typename BasicJsonType,
typename T,
5818 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5819inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5824template<
typename BasicJsonType>
5825inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5830template <
typename BasicJsonType,
typename CompatibleObjectType,
5831 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5832inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5837template<
typename BasicJsonType>
5838inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5844 typename BasicJsonType,
typename T, std::size_t N,
5845 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5848inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5853template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5854inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5856 j = { p.first, p.second };
5860template<
typename BasicJsonType,
typename T,
5861 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
5864 j = { {
b.key(),
b.value()} };
5867template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5870 j = { std::get<Idx>(t)... };
5873template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5874inline void to_json(BasicJsonType& j,
const T& t)
5879#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5880template<
typename BasicJsonType>
5881inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5889 template<
typename BasicJsonType,
typename T>
5890 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5891 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
5893 return to_json(j, std::forward<T>(val));
5898#ifndef JSON_HAS_CPP_17
5907#ifndef JSON_HAS_CPP_17
5919template<
typename ValueType,
typename>
5924 template<
typename BasicJsonType,
typename TargetType = ValueType>
5925 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5926 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5927 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
5929 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5934 template<
typename BasicJsonType,
typename TargetType = ValueType>
5936 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
5937 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
5939 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
5944 template<
typename BasicJsonType,
typename TargetType = ValueType>
5945 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5946 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5947 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
5949 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5977template<
typename BinaryType>
6002 , m_subtype(subtype_)
6003 , m_has_subtype(
true)
6009 , m_subtype(subtype_)
6010 , m_has_subtype(
true)
6015 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
6016 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
6021 return !(rhs == *
this);
6028 m_subtype = subtype_;
6029 m_has_subtype =
true;
6036 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
6043 return m_has_subtype;
6051 m_has_subtype =
false;
6056 bool m_has_subtype =
false;
6080#include <functional>
6092inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6094 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6109template<
typename BasicJsonType>
6110std::size_t hash(
const BasicJsonType& j)
6112 using string_t =
typename BasicJsonType::string_t;
6113 using number_integer_t =
typename BasicJsonType::number_integer_t;
6114 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6115 using number_float_t =
typename BasicJsonType::number_float_t;
6117 const auto type =
static_cast<std::size_t
>(j.type());
6120 case BasicJsonType::value_t::null:
6121 case BasicJsonType::value_t::discarded:
6126 case BasicJsonType::value_t::object:
6129 for (
const auto& element : j.items())
6131 const auto h = std::hash<string_t> {}(element.key());
6133 seed =
combine(seed, hash(element.value()));
6138 case BasicJsonType::value_t::array:
6141 for (
const auto& element : j)
6143 seed =
combine(seed, hash(element));
6148 case BasicJsonType::value_t::string:
6150 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6154 case BasicJsonType::value_t::boolean:
6156 const auto h = std::hash<bool> {}(j.template get<bool>());
6160 case BasicJsonType::value_t::number_integer:
6162 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6166 case BasicJsonType::value_t::number_unsigned:
6168 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6172 case BasicJsonType::value_t::number_float:
6174 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6178 case BasicJsonType::value_t::binary:
6181 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6183 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6184 for (
const auto byte : j.get_binary())
6186 seed =
combine(seed, std::hash<std::uint8_t> {}(
byte));
6223#ifdef __cpp_lib_byteswap
6247#include <type_traits>
6269enum class input_format_t {
json, cbor, msgpack, ubjson, bson, bjdata };
6280class file_input_adapter
6283 using char_type = char;
6286 explicit file_input_adapter(
std::FILE*
f) noexcept
6293 file_input_adapter(
const file_input_adapter&) =
delete;
6294 file_input_adapter(file_input_adapter&&) noexcept = default;
6295 file_input_adapter& operator=(const file_input_adapter&) = delete;
6296 file_input_adapter& operator=(file_input_adapter&&) = delete;
6297 ~file_input_adapter() = default;
6299 std::char_traits<
char>::int_type get_character() noexcept
6301 return std::fgetc(m_file);
6306 std::size_t get_elements(T* dest, std::size_t
count = 1)
6308 return fread(dest, 1,
sizeof(T) *
count, m_file);
6325class input_stream_adapter
6328 using char_type = char;
6330 ~input_stream_adapter()
6336 is->clear(is->rdstate() & std::ios::eofbit);
6340 explicit input_stream_adapter(std::istream& i)
6341 : is(&i), sb(i.rdbuf())
6345 input_stream_adapter(
const input_stream_adapter&) =
delete;
6346 input_stream_adapter& operator=(input_stream_adapter&) =
delete;
6347 input_stream_adapter& operator=(input_stream_adapter&&) =
delete;
6349 input_stream_adapter(input_stream_adapter&& rhs) noexcept
6350 : is(rhs.is), sb(rhs.sb)
6359 std::char_traits<char>::int_type get_character()
6361 auto res = sb->sbumpc();
6365 is->clear(is->rdstate() | std::ios::eofbit);
6371 std::size_t get_elements(T* dest, std::size_t
count = 1)
6373 auto res =
static_cast<std::size_t
>(sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(
count *
sizeof(T))));
6376 is->clear(is->rdstate() | std::ios::eofbit);
6383 std::istream* is =
nullptr;
6384 std::streambuf* sb =
nullptr;
6390template<
typename IteratorType>
6391class iterator_input_adapter
6394 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6396 iterator_input_adapter(IteratorType
first, IteratorType last)
6400 typename char_traits<char_type>::int_type get_character()
6404 auto result = char_traits<char_type>::to_int_type(*current);
6405 std::advance(current, 1);
6409 return char_traits<char_type>::eof();
6414 std::size_t get_elements(T* dest, std::size_t
count = 1)
6416 auto* ptr =
reinterpret_cast<char*
>(dest);
6417 for (std::size_t read_index = 0; read_index <
count *
sizeof(T); ++read_index)
6421 ptr[read_index] =
static_cast<char>(*current);
6422 std::advance(current, 1);
6429 return count *
sizeof(T);
6433 IteratorType current;
6436 template<
typename BaseInputAdapter,
size_t T>
6437 friend struct wide_string_input_helper;
6441 return current ==
end;
6445template<
typename BaseInputAdapter,
size_t T>
6446struct wide_string_input_helper;
6448template<
typename BaseInputAdapter>
6449struct wide_string_input_helper<BaseInputAdapter, 4>
6452 static void fill_buffer(BaseInputAdapter& input,
6453 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6454 size_t& utf8_bytes_index,
6455 size_t& utf8_bytes_filled)
6457 utf8_bytes_index = 0;
6461 utf8_bytes[0] = std::char_traits<char>::eof();
6462 utf8_bytes_filled = 1;
6467 const auto wc = input.get_character();
6472 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6473 utf8_bytes_filled = 1;
6475 else if (wc <= 0x7FF)
6477 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6478 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6479 utf8_bytes_filled = 2;
6481 else if (wc <= 0xFFFF)
6483 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6484 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6485 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6486 utf8_bytes_filled = 3;
6488 else if (wc <= 0x10FFFF)
6490 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6491 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6492 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6493 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6494 utf8_bytes_filled = 4;
6499 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6500 utf8_bytes_filled = 1;
6506template<
typename BaseInputAdapter>
6507struct wide_string_input_helper<BaseInputAdapter, 2>
6510 static void fill_buffer(BaseInputAdapter& input,
6511 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6512 size_t& utf8_bytes_index,
6513 size_t& utf8_bytes_filled)
6515 utf8_bytes_index = 0;
6519 utf8_bytes[0] = std::char_traits<char>::eof();
6520 utf8_bytes_filled = 1;
6525 const auto wc = input.get_character();
6530 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6531 utf8_bytes_filled = 1;
6533 else if (wc <= 0x7FF)
6535 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6536 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6537 utf8_bytes_filled = 2;
6539 else if (0xD800 > wc || wc >= 0xE000)
6541 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6542 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6543 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6544 utf8_bytes_filled = 3;
6550 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6551 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6552 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6553 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6554 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6555 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6556 utf8_bytes_filled = 4;
6560 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6561 utf8_bytes_filled = 1;
6569template<
typename BaseInputAdapter,
typename W
ideCharType>
6570class wide_string_input_adapter
6573 using char_type = char;
6575 wide_string_input_adapter(BaseInputAdapter base)
6576 : base_adapter(base) {}
6578 typename std::char_traits<char>::int_type get_character() noexcept
6581 if (utf8_bytes_index == utf8_bytes_filled)
6583 fill_buffer<sizeof(WideCharType)>();
6591 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6592 return utf8_bytes[utf8_bytes_index++];
6597 std::size_t get_elements(T* , std::size_t = 1)
6603 BaseInputAdapter base_adapter;
6608 wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
6612 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6615 std::size_t utf8_bytes_index = 0;
6617 std::size_t utf8_bytes_filled = 0;
6620template<
typename IteratorType,
typename Enable =
void>
6621struct iterator_input_adapter_factory
6623 using iterator_type = IteratorType;
6624 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6625 using adapter_type = iterator_input_adapter<iterator_type>;
6627 static adapter_type create(IteratorType
first, IteratorType last)
6629 return adapter_type(std::move(
first), std::move(last));
6634struct is_iterator_of_multibyte
6636 using value_type =
typename std::iterator_traits<T>::value_type;
6639 value =
sizeof(value_type) > 1
6643template<
typename IteratorType>
6644struct iterator_input_adapter_factory<IteratorType,
enable_if_t<is_iterator_of_multibyte<IteratorType>::
value>>
6646 using iterator_type = IteratorType;
6647 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6648 using base_adapter_type = iterator_input_adapter<iterator_type>;
6649 using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
6651 static adapter_type create(IteratorType
first, IteratorType last)
6653 return adapter_type(base_adapter_type(std::move(
first), std::move(last)));
6658template<
typename IteratorType>
6659typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType
first, IteratorType last)
6661 using factory_type = iterator_input_adapter_factory<IteratorType>;
6662 return factory_type::create(
first, last);
6669namespace container_input_adapter_factory_impl
6675template<
typename ContainerType,
typename Enable =
void>
6678template<
typename ContainerType>
6680 void_t<decltype(begin(
std::declval<ContainerType>()),
end(std::declval<ContainerType>()))>>
6682 using adapter_type =
decltype(input_adapter(begin(std::declval<ContainerType>()),
end(std::declval<ContainerType>())));
6686 return input_adapter(begin(container),
end(container));
6692template<
typename ContainerType>
6693typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(
const ContainerType& container)
6695 return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
6700inline file_input_adapter input_adapter(std::FILE* file)
6702 if (file ==
nullptr)
6704 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6706 return file_input_adapter(file);
6709inline input_stream_adapter input_adapter(std::istream& stream)
6711 return input_stream_adapter(stream);
6714inline input_stream_adapter input_adapter(std::istream&& stream)
6716 return input_stream_adapter(stream);
6720using contiguous_bytes_input_adapter =
decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
6723template <
typename CharT,
6724 typename std::enable_if <
6725 std::is_pointer<CharT>::value&&
6726 !std::is_array<CharT>::value&&
6727 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6728 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6730contiguous_bytes_input_adapter input_adapter(CharT
b)
6734 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6736 auto length = std::strlen(
reinterpret_cast<const char*
>(
b));
6737 const auto* ptr =
reinterpret_cast<const char*
>(
b);
6738 return input_adapter(ptr, ptr +
length);
6741template<
typename T, std::
size_t N>
6742auto input_adapter(T (&
array)[N]) ->
decltype(input_adapter(
array,
array + N))
6750class span_input_adapter
6753 template <
typename CharT,
6754 typename std::enable_if <
6755 std::is_pointer<CharT>::value&&
6756 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6757 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6759 span_input_adapter(CharT
b, std::size_t l)
6760 : ia(reinterpret_cast<const char*>(
b), reinterpret_cast<const char*>(
b) + l) {}
6762 template<
class IteratorType,
6763 typename std::enable_if<
6764 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6766 span_input_adapter(IteratorType
first, IteratorType last)
6767 : ia(input_adapter(
first, last)) {}
6769 contiguous_bytes_input_adapter&&
get()
6771 return std::move(ia);
6775 contiguous_bytes_input_adapter ia;
6814template<
typename BasicJsonType>
6918 const std::string& last_token,
6944template<
typename BasicJsonType>
6960 : root(
r), allow_exceptions(allow_exceptions_)
6972 handle_value(
nullptr);
7008 handle_value(std::move(val));
7014 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
7016 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7018 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7030 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
7039 ref_stack.back()->set_parents();
7040 ref_stack.pop_back();
7046 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
7048 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7050 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7061 ref_stack.back()->set_parents();
7062 ref_stack.pop_back();
7066 template<
class Exception>
7068 const Exception& ex)
7071 static_cast<void>(ex);
7072 if (allow_exceptions)
7091 template<
typename Value>
7093 BasicJsonType* handle_value(Value&&
v)
7095 if (ref_stack.empty())
7097 root = BasicJsonType(std::forward<Value>(
v));
7101 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7103 if (ref_stack.back()->is_array())
7105 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(
v));
7106 return &(ref_stack.back()->m_data.m_value.array->back());
7111 *object_element = BasicJsonType(std::forward<Value>(
v));
7112 return object_element;
7116 BasicJsonType& root;
7118 std::vector<BasicJsonType*> ref_stack {};
7120 BasicJsonType* object_element =
nullptr;
7122 bool errored =
false;
7124 const bool allow_exceptions =
true;
7127template<
typename BasicJsonType>
7141 const bool allow_exceptions_ =
true)
7142 : root(
r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_)
7144 keep_stack.push_back(
true);
7156 handle_value(
nullptr);
7192 handle_value(std::move(val));
7199 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
7200 keep_stack.push_back(keep);
7202 auto val = handle_value(BasicJsonType::value_t::object,
true);
7203 ref_stack.push_back(val.second);
7206 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7208 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7216 BasicJsonType k = BasicJsonType(val);
7219 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7220 key_keep_stack.push_back(keep);
7223 if (keep && ref_stack.back())
7225 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
7233 if (ref_stack.back())
7235 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7242 ref_stack.back()->set_parents();
7248 ref_stack.pop_back();
7249 keep_stack.pop_back();
7251 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7254 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7256 if (it->is_discarded())
7258 ref_stack.back()->erase(it);
7269 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7270 keep_stack.push_back(keep);
7272 auto val = handle_value(BasicJsonType::value_t::array,
true);
7273 ref_stack.push_back(val.second);
7276 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7278 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7288 if (ref_stack.back())
7290 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7293 ref_stack.back()->set_parents();
7304 ref_stack.pop_back();
7305 keep_stack.pop_back();
7308 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7310 ref_stack.back()->m_data.m_value.array->pop_back();
7316 template<
class Exception>
7318 const Exception& ex)
7321 static_cast<void>(ex);
7322 if (allow_exceptions)
7350 template<
typename Value>
7351 std::pair<bool, BasicJsonType*> handle_value(Value&&
v,
const bool skip_callback =
false)
7357 if (!keep_stack.back())
7359 return {
false,
nullptr};
7363 auto value = BasicJsonType(std::forward<Value>(
v));
7366 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
7371 return {
false,
nullptr};
7374 if (ref_stack.empty())
7376 root = std::move(
value);
7377 return {
true, & root};
7382 if (!ref_stack.back())
7384 return {
false,
nullptr};
7388 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7391 if (ref_stack.back()->is_array())
7393 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(
value));
7394 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
7401 const bool store_element = key_keep_stack.back();
7402 key_keep_stack.pop_back();
7406 return {
false,
nullptr};
7410 *object_element = std::move(
value);
7411 return {
true, object_element};
7415 BasicJsonType& root;
7417 std::vector<BasicJsonType*> ref_stack {};
7419 std::vector<bool> keep_stack {};
7421 std::vector<bool> key_keep_stack {};
7423 BasicJsonType* object_element =
nullptr;
7425 bool errored =
false;
7427 const parser_callback_t callback =
nullptr;
7429 const bool allow_exceptions =
true;
7431 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7434template<
typename BasicJsonType>
7529#include <initializer_list>
7551template<
typename BasicJsonType>
7584 case token_type::uninitialized:
7585 return "<uninitialized>";
7586 case token_type::literal_true:
7587 return "true literal";
7588 case token_type::literal_false:
7589 return "false literal";
7590 case token_type::literal_null:
7591 return "null literal";
7592 case token_type::value_string:
7593 return "string literal";
7594 case token_type::value_unsigned:
7595 case token_type::value_integer:
7596 case token_type::value_float:
7597 return "number literal";
7598 case token_type::begin_array:
7600 case token_type::begin_object:
7602 case token_type::end_array:
7604 case token_type::end_object:
7606 case token_type::name_separator:
7608 case token_type::value_separator:
7610 case token_type::parse_error:
7611 return "<parse error>";
7612 case token_type::end_of_input:
7613 return "end of input";
7614 case token_type::literal_or_value:
7615 return "'[', '{', or a literal";
7618 return "unknown token";
7628template<
typename BasicJsonType,
typename InputAdapterType>
7631 using number_integer_t =
typename BasicJsonType::number_integer_t;
7632 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7633 using number_float_t =
typename BasicJsonType::number_float_t;
7634 using string_t =
typename BasicJsonType::string_t;
7635 using char_type =
typename InputAdapterType::char_type;
7641 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7642 : ia(
std::move(adapter))
7643 , ignore_comments(ignore_comments_)
7644 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7661 static char get_decimal_point() noexcept
7663 const auto* loc = localeconv();
7665 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7693 const auto factors = { 12u, 8u, 4u, 0u };
7694 for (
const auto factor : factors)
7698 if (current >=
'0' && current <=
'9')
7700 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7702 else if (current >=
'A' && current <=
'F')
7704 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7706 else if (current >=
'a' && current <=
'f')
7708 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7716 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7735 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7737 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7740 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7749 error_message =
"invalid string: ill-formed UTF-8 byte";
7772 token_type scan_string()
7786 case char_traits<char_type>::eof():
7788 error_message =
"invalid string: missing closing quote";
7789 return token_type::parse_error;
7795 return token_type::value_string;
7839 const int codepoint1 = get_codepoint();
7840 int codepoint = codepoint1;
7844 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7845 return token_type::parse_error;
7849 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7854 const int codepoint2 = get_codepoint();
7858 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7859 return token_type::parse_error;
7866 codepoint =
static_cast<int>(
7868 (
static_cast<unsigned int>(codepoint1) << 10u)
7870 +
static_cast<unsigned int>(codepoint2)
7878 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7879 return token_type::parse_error;
7884 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7885 return token_type::parse_error;
7892 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7893 return token_type::parse_error;
7898 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7901 if (codepoint < 0x80)
7904 add(
static_cast<char_int_type
>(codepoint));
7906 else if (codepoint <= 0x7FF)
7909 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7910 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7912 else if (codepoint <= 0xFFFF)
7915 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7916 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7917 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7922 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7923 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7924 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7925 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7933 error_message =
"invalid string: forbidden character after backslash";
7934 return token_type::parse_error;
7943 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7944 return token_type::parse_error;
7949 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7950 return token_type::parse_error;
7955 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7956 return token_type::parse_error;
7961 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7962 return token_type::parse_error;
7967 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7968 return token_type::parse_error;
7973 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7974 return token_type::parse_error;
7979 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7980 return token_type::parse_error;
7985 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7986 return token_type::parse_error;
7991 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7992 return token_type::parse_error;
7997 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7998 return token_type::parse_error;
8003 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
8004 return token_type::parse_error;
8009 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
8010 return token_type::parse_error;
8015 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
8016 return token_type::parse_error;
8021 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
8022 return token_type::parse_error;
8027 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
8028 return token_type::parse_error;
8033 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
8034 return token_type::parse_error;
8039 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
8040 return token_type::parse_error;
8045 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
8046 return token_type::parse_error;
8051 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
8052 return token_type::parse_error;
8057 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
8058 return token_type::parse_error;
8063 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
8064 return token_type::parse_error;
8069 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
8070 return token_type::parse_error;
8075 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
8076 return token_type::parse_error;
8081 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
8082 return token_type::parse_error;
8087 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
8088 return token_type::parse_error;
8093 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
8094 return token_type::parse_error;
8099 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
8100 return token_type::parse_error;
8105 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
8106 return token_type::parse_error;
8111 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
8112 return token_type::parse_error;
8117 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
8118 return token_type::parse_error;
8123 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
8124 return token_type::parse_error;
8129 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
8130 return token_type::parse_error;
8267 return token_type::parse_error;
8277 return token_type::parse_error;
8301 return token_type::parse_error;
8311 return token_type::parse_error;
8321 return token_type::parse_error;
8333 return token_type::parse_error;
8343 return token_type::parse_error;
8351 error_message =
"invalid string: ill-formed UTF-8 byte";
8352 return token_type::parse_error;
8375 case char_traits<char_type>::eof():
8392 case char_traits<char_type>::eof():
8395 error_message =
"invalid comment; missing closing '*/'";
8423 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8430 static
void strtof(
float&
f, const
char* str,
char** endptr) noexcept
8432 f = std::strtof(str, endptr);
8436 static
void strtof(
double&
f, const
char* str,
char** endptr) noexcept
8438 f = std::strtod(str, endptr);
8442 static
void strtof(
long double&
f, const
char* str,
char** endptr) noexcept
8444 f = std::strtold(str, endptr);
8487 token_type scan_number()
8494 token_type number_type = token_type::value_unsigned;
8502 goto scan_number_minus;
8508 goto scan_number_zero;
8522 goto scan_number_any1;
8532 number_type = token_type::value_integer;
8538 goto scan_number_zero;
8552 goto scan_number_any1;
8557 error_message =
"invalid number; expected digit after '-'";
8558 return token_type::parse_error;
8568 add(decimal_point_char);
8569 decimal_point_position = token_buffer.size() - 1;
8570 goto scan_number_decimal1;
8577 goto scan_number_exponent;
8581 goto scan_number_done;
8600 goto scan_number_any1;
8605 add(decimal_point_char);
8606 decimal_point_position = token_buffer.size() - 1;
8607 goto scan_number_decimal1;
8614 goto scan_number_exponent;
8618 goto scan_number_done;
8621scan_number_decimal1:
8623 number_type = token_type::value_float;
8638 goto scan_number_decimal2;
8643 error_message =
"invalid number; expected digit after '.'";
8644 return token_type::parse_error;
8648scan_number_decimal2:
8664 goto scan_number_decimal2;
8671 goto scan_number_exponent;
8675 goto scan_number_done;
8678scan_number_exponent:
8680 number_type = token_type::value_float;
8687 goto scan_number_sign;
8702 goto scan_number_any2;
8708 "invalid number; expected '+', '-', or digit after exponent";
8709 return token_type::parse_error;
8729 goto scan_number_any2;
8734 error_message =
"invalid number; expected digit after exponent sign";
8735 return token_type::parse_error;
8755 goto scan_number_any2;
8759 goto scan_number_done;
8767 char* endptr =
nullptr;
8771 if (number_type == token_type::value_unsigned)
8773 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8776 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8778 if (errno != ERANGE)
8780 value_unsigned =
static_cast<number_unsigned_t
>(
x);
8781 if (value_unsigned ==
x)
8783 return token_type::value_unsigned;
8787 else if (number_type == token_type::value_integer)
8789 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8792 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8794 if (errno != ERANGE)
8796 value_integer =
static_cast<number_integer_t
>(
x);
8797 if (value_integer ==
x)
8799 return token_type::value_integer;
8806 strtof(value_float, token_buffer.data(), &endptr);
8809 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8811 return token_type::value_float;
8820 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8821 token_type return_type)
8823 JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]);
8824 for (std::size_t i = 1; i <
length; ++i)
8828 error_message =
"invalid literal";
8829 return token_type::parse_error;
8840 void reset() noexcept
8842 token_buffer.clear();
8843 token_string.clear();
8844 decimal_point_position = std::string::npos;
8845 token_string.push_back(char_traits<char_type>::to_char_type(current));
8860 ++position.chars_read_total;
8861 ++position.chars_read_current_line;
8870 current = ia.get_character();
8875 token_string.push_back(char_traits<char_type>::to_char_type(current));
8878 if (current ==
'\n')
8880 ++position.lines_read;
8881 position.chars_read_current_line = 0;
8899 --position.chars_read_total;
8902 if (position.chars_read_current_line == 0)
8904 if (position.lines_read > 0)
8906 --position.lines_read;
8911 --position.chars_read_current_line;
8917 token_string.pop_back();
8922 void add(char_int_type c)
8924 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8935 return value_integer;
8941 return value_unsigned;
8954 if (decimal_point_char !=
'.' && decimal_point_position != std::string::npos)
8956 token_buffer[decimal_point_position] =
'.';
8958 return token_buffer;
8978 for (
const auto c : token_string)
8980 if (
static_cast<unsigned char>(c) <=
'\x1F')
8983 std::array<char, 9> cs{{}};
8984 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8985 result += cs.data();
8990 result.push_back(
static_cast<std::string::value_type
>(c));
9001 return error_message;
9017 return get() == 0xBB &&
get() == 0xBF;
9032 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
9038 if (position.chars_read_total == 0 && !skip_bom())
9040 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
9041 return token_type::parse_error;
9048 while (ignore_comments && current ==
'/')
9050 if (!scan_comment())
9052 return token_type::parse_error;
9063 return token_type::begin_array;
9065 return token_type::end_array;
9067 return token_type::begin_object;
9069 return token_type::end_object;
9071 return token_type::name_separator;
9073 return token_type::value_separator;
9078 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
9079 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
9083 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
9084 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
9088 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
9089 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
9094 return scan_string();
9108 return scan_number();
9114 return token_type::end_of_input;
9118 error_message =
"invalid literal";
9119 return token_type::parse_error;
9125 InputAdapterType ia;
9128 const bool ignore_comments =
false;
9134 bool next_unget =
false;
9140 std::vector<char_type> token_string {};
9143 string_t token_buffer {};
9146 const char* error_message =
"";
9149 number_integer_t value_integer = 0;
9150 number_unsigned_t value_unsigned = 0;
9151 number_float_t value_float = 0;
9154 const char_int_type decimal_point_char =
'.';
9156 std::size_t decimal_point_position = std::string::npos;
9191using null_function_t =
decltype(std::declval<T&>().null());
9194using boolean_function_t =
9195 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9197template<
typename T,
typename Integer>
9198using number_integer_function_t =
9199 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9201template<
typename T,
typename Un
signed>
9202using number_unsigned_function_t =
9203 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9205template<
typename T,
typename Float,
typename String>
9206using number_float_function_t =
decltype(std::declval<T&>().number_float(
9207 std::declval<Float>(), std::declval<const String&>()));
9209template<
typename T,
typename String>
9210using string_function_t =
9211 decltype(std::declval<T&>().string(std::declval<String&>()));
9213template<
typename T,
typename Binary>
9214using binary_function_t =
9215 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9218using start_object_function_t =
9219 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9221template<
typename T,
typename String>
9222using key_function_t =
9223 decltype(std::declval<T&>().key(std::declval<String&>()));
9226using end_object_function_t =
decltype(std::declval<T&>().end_object());
9229using start_array_function_t =
9230 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9233using end_array_function_t =
decltype(std::declval<T&>().end_array());
9235template<
typename T,
typename Exception>
9236using parse_error_function_t =
decltype(std::declval<T&>().parse_error(
9237 std::declval<std::size_t>(), std::declval<const std::string&>(),
9238 std::declval<const Exception&>()));
9240template<
typename SAX,
typename BasicJsonType>
9244 static_assert(is_basic_json<BasicJsonType>::value,
9245 "BasicJsonType must be of type basic_json<...>");
9247 using number_integer_t =
typename BasicJsonType::number_integer_t;
9248 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9249 using number_float_t =
typename BasicJsonType::number_float_t;
9250 using string_t =
typename BasicJsonType::string_t;
9251 using binary_t =
typename BasicJsonType::binary_t;
9252 using exception_t =
typename BasicJsonType::exception;
9255 static constexpr bool value =
9256 is_detected_exact<bool, null_function_t, SAX>::value &&
9257 is_detected_exact<bool, boolean_function_t, SAX>::value &&
9258 is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
9259 is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
9260 is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
9261 is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
9262 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
9263 is_detected_exact<bool, start_object_function_t, SAX>::value &&
9264 is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
9265 is_detected_exact<bool, end_object_function_t, SAX>::value &&
9266 is_detected_exact<bool, start_array_function_t, SAX>::value &&
9267 is_detected_exact<bool, end_array_function_t, SAX>::value &&
9268 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
9271template<
typename SAX,
typename BasicJsonType>
9272struct is_sax_static_asserts
9275 static_assert(is_basic_json<BasicJsonType>::value,
9276 "BasicJsonType must be of type basic_json<...>");
9278 using number_integer_t =
typename BasicJsonType::number_integer_t;
9279 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9280 using number_float_t =
typename BasicJsonType::number_float_t;
9281 using string_t =
typename BasicJsonType::string_t;
9282 using binary_t =
typename BasicJsonType::binary_t;
9283 using exception_t =
typename BasicJsonType::exception;
9286 static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
9287 "Missing/invalid function: bool null()");
9288 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
9289 "Missing/invalid function: bool boolean(bool)");
9290 static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
9291 "Missing/invalid function: bool boolean(bool)");
9295 "Missing/invalid function: bool number_integer(number_integer_t)");
9299 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9301 number_float_t, string_t>
::value,
9302 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9304 is_detected_exact<bool, string_function_t, SAX, string_t>::value,
9305 "Missing/invalid function: bool string(string_t&)");
9307 is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
9308 "Missing/invalid function: bool binary(binary_t&)");
9309 static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
9310 "Missing/invalid function: bool start_object(std::size_t)");
9311 static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
9312 "Missing/invalid function: bool key(string_t&)");
9313 static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
9314 "Missing/invalid function: bool end_object()");
9315 static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
9316 "Missing/invalid function: bool start_array(std::size_t)");
9317 static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
9318 "Missing/invalid function: bool end_array()");
9320 is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
9321 "Missing/invalid function: bool parse_error(std::size_t, const "
9322 "std::string&, const exception&)");
9354static inline bool little_endianness(
int num = 1) noexcept
9356 return *
reinterpret_cast<char*
>(&num) == 1;
9366template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9369 using number_integer_t =
typename BasicJsonType::number_integer_t;
9370 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9371 using number_float_t =
typename BasicJsonType::number_float_t;
9372 using string_t =
typename BasicJsonType::string_t;
9373 using binary_t =
typename BasicJsonType::binary_t;
9374 using json_sax_t = SAX;
9375 using char_type =
typename InputAdapterType::char_type;
9384 explicit binary_reader(InputAdapterType&& adapter,
const input_format_t
format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(
format)
9386 (
void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
9407 const
bool strict = true,
9411 bool result =
false;
9415 case input_format_t::bson:
9416 result = parse_bson_internal();
9419 case input_format_t::cbor:
9420 result = parse_cbor_internal(
true, tag_handler);
9423 case input_format_t::msgpack:
9424 result = parse_msgpack_internal();
9427 case input_format_t::ubjson:
9428 case input_format_t::bjdata:
9429 result = parse_ubjson_internal();
9432 case input_format_t::json:
9440 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9451 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9452 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9468 bool parse_bson_internal()
9470 std::int32_t document_size{};
9471 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9483 return sax->end_object();
9493 bool get_bson_cstr(string_t& result)
9495 auto out = std::back_inserter(result);
9503 if (current == 0x00)
9507 *out++ =
static_cast<typename string_t::value_type
>(current);
9522 template<
typename NumberType>
9523 bool get_bson_string(
const NumberType len, string_t& result)
9527 auto last_token = get_token_string();
9529 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
9532 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != char_traits<char_type>::eof();
9544 template<
typename NumberType>
9545 bool get_bson_binary(
const NumberType len, binary_t& result)
9549 auto last_token = get_token_string();
9551 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
9555 std::uint8_t subtype{};
9556 get_number<std::uint8_t>(input_format_t::bson, subtype);
9557 result.set_subtype(subtype);
9559 return get_binary(input_format_t::bson, len, result);
9572 bool parse_bson_element_internal(
const char_int_type element_type,
9573 const std::size_t element_type_parse_position)
9575 switch (element_type)
9580 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9587 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
9592 return parse_bson_internal();
9597 return parse_bson_array();
9604 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
9609 return sax->boolean(get() != 0);
9619 std::int32_t
value{};
9620 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9625 std::int64_t
value{};
9626 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9631 std::array<char, 3> cr{{}};
9632 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9633 const std::string cr_str{cr.data()};
9634 return sax->parse_error(element_type_parse_position, cr_str,
9652 bool parse_bson_element_list(
const bool is_array)
9656 while (
auto element_type = get())
9663 const std::size_t element_type_parse_position = chars_read;
9669 if (!is_array && !sax->key(key))
9674 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9690 bool parse_bson_array()
9692 std::int32_t document_size{};
9693 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9705 return sax->end_array();
9720 bool parse_cbor_internal(
const bool get_char,
9723 switch (get_char ? get() : current)
9726 case char_traits<char_type>::eof():
9727 return unexpect_eof(input_format_t::cbor,
"value");
9754 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9758 std::uint8_t number{};
9759 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9764 std::uint16_t number{};
9765 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9770 std::uint32_t number{};
9771 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9776 std::uint64_t number{};
9777 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9805 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9809 std::uint8_t number{};
9810 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9815 std::uint16_t number{};
9816 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9821 std::uint32_t number{};
9822 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9827 std::uint64_t number{};
9828 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9829 -
static_cast<number_integer_t
>(number));
9864 return get_cbor_binary(
b) && sax->binary(
b);
9899 return get_cbor_string(s) && sax->string(s);
9927 return get_cbor_array(
9928 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9933 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9938 std::uint16_t len{};
9939 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9944 std::uint32_t len{};
9945 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9950 std::uint64_t len{};
9951 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9955 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9982 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9987 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9992 std::uint16_t len{};
9993 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9998 std::uint32_t len{};
9999 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10004 std::uint64_t len{};
10005 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10009 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
10031 switch (tag_handler)
10035 auto last_token = get_token_string();
10037 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10047 std::uint8_t subtype_to_ignore{};
10048 get_number(input_format_t::cbor, subtype_to_ignore);
10053 std::uint16_t subtype_to_ignore{};
10054 get_number(input_format_t::cbor, subtype_to_ignore);
10059 std::uint32_t subtype_to_ignore{};
10060 get_number(input_format_t::cbor, subtype_to_ignore);
10065 std::uint64_t subtype_to_ignore{};
10066 get_number(input_format_t::cbor, subtype_to_ignore);
10072 return parse_cbor_internal(
true, tag_handler);
10083 std::uint8_t subtype{};
10084 get_number(input_format_t::cbor, subtype);
10085 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10090 std::uint16_t subtype{};
10091 get_number(input_format_t::cbor, subtype);
10092 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10097 std::uint32_t subtype{};
10098 get_number(input_format_t::cbor, subtype);
10099 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10104 std::uint64_t subtype{};
10105 get_number(input_format_t::cbor, subtype);
10106 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
10110 return parse_cbor_internal(
true, tag_handler);
10113 return get_cbor_binary(
b) && sax->binary(
b);
10123 return sax->boolean(
false);
10126 return sax->boolean(
true);
10129 return sax->null();
10133 const auto byte1_raw = get();
10138 const auto byte2_raw = get();
10144 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10145 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10155 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10156 const double val = [&half]
10158 const int exp = (half >> 10u) & 0x1Fu;
10159 const unsigned int mant = half & 0x3FFu;
10165 return std::ldexp(mant, -24);
10168 ? std::numeric_limits<double>::infinity()
10169 :
std::numeric_limits<double>::quiet_NaN();
10171 return std::ldexp(mant + 1024, exp - 25);
10174 return sax->number_float((half & 0x8000u) != 0
10175 ?
static_cast<number_float_t
>(-val)
10176 : static_cast<number_float_t>(val),
"");
10182 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10188 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10193 auto last_token = get_token_string();
10195 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10211 bool get_cbor_string(string_t& result)
10246 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10251 std::uint8_t len{};
10252 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10257 std::uint16_t len{};
10258 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10263 std::uint32_t len{};
10264 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10269 std::uint64_t len{};
10270 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10275 while (get() != 0xFF)
10278 if (!get_cbor_string(chunk))
10282 result.append(chunk);
10289 auto last_token = get_token_string();
10291 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10307 bool get_cbor_binary(binary_t& result)
10342 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10347 std::uint8_t len{};
10348 return get_number(input_format_t::cbor, len) &&
10349 get_binary(input_format_t::cbor, len, result);
10354 std::uint16_t len{};
10355 return get_number(input_format_t::cbor, len) &&
10356 get_binary(input_format_t::cbor, len, result);
10361 std::uint32_t len{};
10362 return get_number(input_format_t::cbor, len) &&
10363 get_binary(input_format_t::cbor, len, result);
10368 std::uint64_t len{};
10369 return get_number(input_format_t::cbor, len) &&
10370 get_binary(input_format_t::cbor, len, result);
10375 while (get() != 0xFF)
10378 if (!get_cbor_binary(chunk))
10382 result.insert(result.end(), chunk.begin(), chunk.end());
10389 auto last_token = get_token_string();
10391 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10402 bool get_cbor_array(
const std::size_t len,
10410 if (len !=
static_cast<std::size_t
>(-1))
10412 for (std::size_t i = 0; i < len; ++i)
10422 while (get() != 0xFF)
10431 return sax->end_array();
10440 bool get_cbor_object(
const std::size_t len,
10451 if (len !=
static_cast<std::size_t
>(-1))
10453 for (std::size_t i = 0; i < len; ++i)
10470 while (get() != 0xFF)
10486 return sax->end_object();
10496 bool parse_msgpack_internal()
10501 case char_traits<char_type>::eof():
10502 return unexpect_eof(input_format_t::msgpack,
"value");
10633 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10652 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10671 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10711 return get_msgpack_string(s) && sax->string(s);
10715 return sax->null();
10718 return sax->boolean(
false);
10721 return sax->boolean(
true);
10736 return get_msgpack_binary(
b) && sax->binary(
b);
10742 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10748 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10753 std::uint8_t number{};
10754 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10759 std::uint16_t number{};
10760 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10765 std::uint32_t number{};
10766 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10771 std::uint64_t number{};
10772 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10777 std::int8_t number{};
10778 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10783 std::int16_t number{};
10784 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10789 std::int32_t number{};
10790 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10795 std::int64_t number{};
10796 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10801 std::uint16_t len{};
10802 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
10807 std::uint32_t len{};
10808 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10813 std::uint16_t len{};
10814 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
10819 std::uint32_t len{};
10820 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10856 return sax->number_integer(
static_cast<std::int8_t
>(current));
10860 auto last_token = get_token_string();
10862 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10877 bool get_msgpack_string(string_t& result)
10920 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
10925 std::uint8_t len{};
10926 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10931 std::uint16_t len{};
10932 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10937 std::uint32_t len{};
10938 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10943 auto last_token = get_token_string();
10945 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10960 bool get_msgpack_binary(binary_t& result)
10963 auto assign_and_return_true = [&result](std::int8_t subtype)
10965 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10973 std::uint8_t len{};
10974 return get_number(input_format_t::msgpack, len) &&
10975 get_binary(input_format_t::msgpack, len, result);
10980 std::uint16_t len{};
10981 return get_number(input_format_t::msgpack, len) &&
10982 get_binary(input_format_t::msgpack, len, result);
10987 std::uint32_t len{};
10988 return get_number(input_format_t::msgpack, len) &&
10989 get_binary(input_format_t::msgpack, len, result);
10994 std::uint8_t len{};
10995 std::int8_t subtype{};
10996 return get_number(input_format_t::msgpack, len) &&
10997 get_number(input_format_t::msgpack, subtype) &&
10998 get_binary(input_format_t::msgpack, len, result) &&
10999 assign_and_return_true(subtype);
11004 std::uint16_t len{};
11005 std::int8_t subtype{};
11006 return get_number(input_format_t::msgpack, len) &&
11007 get_number(input_format_t::msgpack, subtype) &&
11008 get_binary(input_format_t::msgpack, len, result) &&
11009 assign_and_return_true(subtype);
11014 std::uint32_t len{};
11015 std::int8_t subtype{};
11016 return get_number(input_format_t::msgpack, len) &&
11017 get_number(input_format_t::msgpack, subtype) &&
11018 get_binary(input_format_t::msgpack, len, result) &&
11019 assign_and_return_true(subtype);
11024 std::int8_t subtype{};
11025 return get_number(input_format_t::msgpack, subtype) &&
11026 get_binary(input_format_t::msgpack, 1, result) &&
11027 assign_and_return_true(subtype);
11032 std::int8_t subtype{};
11033 return get_number(input_format_t::msgpack, subtype) &&
11034 get_binary(input_format_t::msgpack, 2, result) &&
11035 assign_and_return_true(subtype);
11040 std::int8_t subtype{};
11041 return get_number(input_format_t::msgpack, subtype) &&
11042 get_binary(input_format_t::msgpack, 4, result) &&
11043 assign_and_return_true(subtype);
11048 std::int8_t subtype{};
11049 return get_number(input_format_t::msgpack, subtype) &&
11050 get_binary(input_format_t::msgpack, 8, result) &&
11051 assign_and_return_true(subtype);
11056 std::int8_t subtype{};
11057 return get_number(input_format_t::msgpack, subtype) &&
11058 get_binary(input_format_t::msgpack, 16, result) &&
11059 assign_and_return_true(subtype);
11071 bool get_msgpack_array(
const std::size_t len)
11078 for (std::size_t i = 0; i < len; ++i)
11086 return sax->end_array();
11093 bool get_msgpack_object(
const std::size_t len)
11101 for (std::size_t i = 0; i < len; ++i)
11116 return sax->end_object();
11130 bool parse_ubjson_internal(
const bool get_char =
true)
11132 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11149 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11165 std::uint8_t len{};
11166 return get_number(input_format, len) && get_string(input_format, len, result);
11172 return get_number(input_format, len) && get_string(input_format, len, result);
11177 std::int16_t len{};
11178 return get_number(input_format, len) && get_string(input_format, len, result);
11183 std::int32_t len{};
11184 return get_number(input_format, len) && get_string(input_format, len, result);
11189 std::int64_t len{};
11190 return get_number(input_format, len) && get_string(input_format, len, result);
11195 if (input_format != input_format_t::bjdata)
11199 std::uint16_t len{};
11200 return get_number(input_format, len) && get_string(input_format, len, result);
11205 if (input_format != input_format_t::bjdata)
11209 std::uint32_t len{};
11210 return get_number(input_format, len) && get_string(input_format, len, result);
11215 if (input_format != input_format_t::bjdata)
11219 std::uint64_t len{};
11220 return get_number(input_format, len) && get_string(input_format, len, result);
11226 auto last_token = get_token_string();
11227 std::string message;
11229 if (input_format != input_format_t::bjdata)
11231 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11235 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11237 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11244 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11246 std::pair<std::size_t, char_int_type> size_and_type;
11248 bool no_ndarray =
true;
11255 if (size_and_type.first != npos)
11257 if (size_and_type.second != 0)
11259 if (size_and_type.second !=
'N')
11261 for (std::size_t i = 0; i < size_and_type.first; ++i)
11267 dim.push_back(dimlen);
11273 for (std::size_t i = 0; i < size_and_type.first; ++i)
11279 dim.push_back(dimlen);
11285 while (current !=
']')
11291 dim.push_back(dimlen);
11309 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11313 prefix = get_ignore_noop();
11320 std::uint8_t number{};
11325 result =
static_cast<std::size_t
>(number);
11331 std::int8_t number{};
11338 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11339 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11341 result =
static_cast<std::size_t
>(number);
11347 std::int16_t number{};
11354 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11355 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11357 result =
static_cast<std::size_t
>(number);
11363 std::int32_t number{};
11370 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11371 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11373 result =
static_cast<std::size_t
>(number);
11379 std::int64_t number{};
11386 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11387 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11389 if (!value_in_range_of<std::size_t>(number))
11392 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11394 result =
static_cast<std::size_t
>(number);
11400 if (input_format != input_format_t::bjdata)
11404 std::uint16_t number{};
11409 result =
static_cast<std::size_t
>(number);
11415 if (input_format != input_format_t::bjdata)
11419 std::uint32_t number{};
11424 result = conditional_static_cast<std::size_t>(number);
11430 if (input_format != input_format_t::bjdata)
11434 std::uint64_t number{};
11439 if (!value_in_range_of<std::size_t>(number))
11442 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11444 result = detail::conditional_static_cast<std::size_t>(number);
11450 if (input_format != input_format_t::bjdata)
11456 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11458 std::vector<size_t> dim;
11463 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11465 result = dim.at(dim.size() - 1);
11479 string_t key =
"_ArraySize_";
11480 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
11488 if (result == 0 || result == npos)
11490 return sax->parse_error(chars_read, get_token_string(),
out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
11498 return sax->end_array();
11507 auto last_token = get_token_string();
11508 std::string message;
11510 if (input_format != input_format_t::bjdata)
11512 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11516 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11518 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11532 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
11534 result.first = npos;
11536 bool is_ndarray =
false;
11540 if (current ==
'$')
11542 result.second = get();
11543 if (input_format == input_format_t::bjdata
11544 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11546 auto last_token = get_token_string();
11548 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11563 auto last_token = get_token_string();
11565 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11568 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11569 if (input_format == input_format_t::bjdata && is_ndarray)
11571 if (inside_ndarray)
11573 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11574 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11576 result.second |= (1 << 8);
11581 if (current ==
'#')
11583 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11584 if (input_format == input_format_t::bjdata && is_ndarray)
11586 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11587 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11599 bool get_ubjson_value(
const char_int_type prefix)
11603 case char_traits<char_type>::eof():
11604 return unexpect_eof(input_format,
"value");
11607 return sax->boolean(
true);
11609 return sax->boolean(
false);
11612 return sax->null();
11616 std::uint8_t number{};
11617 return get_number(input_format, number) && sax->number_unsigned(number);
11622 std::int8_t number{};
11623 return get_number(input_format, number) && sax->number_integer(number);
11628 std::int16_t number{};
11629 return get_number(input_format, number) && sax->number_integer(number);
11634 std::int32_t number{};
11635 return get_number(input_format, number) && sax->number_integer(number);
11640 std::int64_t number{};
11641 return get_number(input_format, number) && sax->number_integer(number);
11646 if (input_format != input_format_t::bjdata)
11650 std::uint16_t number{};
11651 return get_number(input_format, number) && sax->number_unsigned(number);
11656 if (input_format != input_format_t::bjdata)
11660 std::uint32_t number{};
11661 return get_number(input_format, number) && sax->number_unsigned(number);
11666 if (input_format != input_format_t::bjdata)
11670 std::uint64_t number{};
11671 return get_number(input_format, number) && sax->number_unsigned(number);
11676 if (input_format != input_format_t::bjdata)
11680 const auto byte1_raw = get();
11685 const auto byte2_raw = get();
11691 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11692 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11702 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11703 const double val = [&half]
11705 const int exp = (half >> 10u) & 0x1Fu;
11706 const unsigned int mant = half & 0x3FFu;
11712 return std::ldexp(mant, -24);
11715 ? std::numeric_limits<double>::infinity()
11716 :
std::numeric_limits<double>::quiet_NaN();
11718 return std::ldexp(mant + 1024, exp - 25);
11721 return sax->number_float((half & 0x8000u) != 0
11722 ?
static_cast<number_float_t
>(-val)
11723 : static_cast<number_float_t>(val),
"");
11729 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11735 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11740 return get_ubjson_high_precision_number();
11752 auto last_token = get_token_string();
11754 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11756 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11757 return sax->string(s);
11763 return get_ubjson_string(s) && sax->string(s);
11767 return get_ubjson_array();
11770 return get_ubjson_object();
11775 auto last_token = get_token_string();
11776 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11782 bool get_ubjson_array()
11784 std::pair<std::size_t, char_int_type> size_and_type;
11793 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11795 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11796 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p, char_int_type t)
11798 return p.first < t;
11800 string_t key =
"_ArrayType_";
11803 auto last_token = get_token_string();
11805 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11808 string_t
type = it->second;
11814 if (size_and_type.second ==
'C')
11816 size_and_type.second =
'U';
11819 key =
"_ArrayData_";
11825 for (std::size_t i = 0; i < size_and_type.first; ++i)
11833 return (sax->end_array() && sax->end_object());
11836 if (size_and_type.first != npos)
11843 if (size_and_type.second != 0)
11845 if (size_and_type.second !=
'N')
11847 for (std::size_t i = 0; i < size_and_type.first; ++i)
11858 for (std::size_t i = 0; i < size_and_type.first; ++i)
11874 while (current !=
']')
11884 return sax->end_array();
11890 bool get_ubjson_object()
11892 std::pair<std::size_t, char_int_type> size_and_type;
11899 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11901 auto last_token = get_token_string();
11903 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11907 if (size_and_type.first != npos)
11914 if (size_and_type.second != 0)
11916 for (std::size_t i = 0; i < size_and_type.first; ++i)
11931 for (std::size_t i = 0; i < size_and_type.first; ++i)
11952 while (current !=
'}')
11967 return sax->end_object();
11973 bool get_ubjson_high_precision_number()
11976 std::size_t
size{};
11977 bool no_ndarray =
true;
11978 auto res = get_ubjson_size_value(
size, no_ndarray);
11985 std::vector<char> number_vector;
11986 for (std::size_t i = 0; i <
size; ++i)
11993 number_vector.push_back(
static_cast<char>(current));
11997 using ia_type =
decltype(detail::input_adapter(number_vector));
11999 const auto result_number = number_lexer.scan();
12000 const auto number_string = number_lexer.get_token_string();
12001 const auto result_remainder = number_lexer.scan();
12008 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12011 switch (result_number)
12013 case token_type::value_integer:
12014 return sax->number_integer(number_lexer.get_number_integer());
12015 case token_type::value_unsigned:
12016 return sax->number_unsigned(number_lexer.get_number_unsigned());
12017 case token_type::value_float:
12018 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12019 case token_type::uninitialized:
12020 case token_type::literal_true:
12021 case token_type::literal_false:
12022 case token_type::literal_null:
12023 case token_type::value_string:
12024 case token_type::begin_array:
12025 case token_type::begin_object:
12026 case token_type::end_array:
12027 case token_type::end_object:
12028 case token_type::name_separator:
12029 case token_type::value_separator:
12030 case token_type::parse_error:
12031 case token_type::end_of_input:
12032 case token_type::literal_or_value:
12035 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12052 char_int_type get()
12055 return current = ia.get_character();
12067 bool get_to(T& dest,
const input_format_t
format,
const char* context)
12069 auto new_chars_read = ia.get_elements(&dest);
12070 chars_read += new_chars_read;
12075 sax->parse_error(chars_read,
"<end of file>",
parse_error::create(110, chars_read, exception_message(
format,
"unexpected end of input", context),
nullptr));
12084 char_int_type get_ignore_noop()
12090 while (current ==
'N');
12095 template<
class NumberType>
12096 static void byte_swap(NumberType& number)
12098 constexpr std::size_t sz =
sizeof(number);
12099#ifdef __cpp_lib_byteswap
12100 if constexpr (sz == 1)
12104 if constexpr(std::is_integral_v<NumberType>)
12106 number = std::byteswap(number);
12110 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12111 for (std::size_t i = 0; i < sz / 2; ++i)
12132 template<
typename NumberType,
bool InputIsLittleEndian = false>
12133 bool get_number(
const input_format_t
format, NumberType& result)
12141 if (is_little_endian != (InputIsLittleEndian ||
format == input_format_t::bjdata))
12162 template<
typename NumberType>
12163 bool get_string(
const input_format_t
format,
12164 const NumberType len,
12167 bool success =
true;
12168 for (NumberType i = 0; i < len; i++)
12176 result.push_back(
static_cast<typename string_t::value_type
>(current));
12195 template<
typename NumberType>
12196 bool get_binary(
const input_format_t
format,
12197 const NumberType len,
12200 bool success =
true;
12201 for (NumberType i = 0; i < len; i++)
12209 result.push_back(
static_cast<std::uint8_t
>(current));
12220 bool unexpect_eof(const input_format_t
format, const
char* context)
const
12224 return sax->parse_error(chars_read,
"<end of file>",
12233 std::string get_token_string()
const
12235 std::array<char, 3> cr{{}};
12236 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12237 return std::string{cr.data()};
12246 std::string exception_message(
const input_format_t
format,
12247 const std::string&
detail,
12248 const std::string& context)
const
12250 std::string error_msg =
"syntax error while parsing ";
12254 case input_format_t::cbor:
12255 error_msg +=
"CBOR";
12258 case input_format_t::msgpack:
12259 error_msg +=
"MessagePack";
12262 case input_format_t::ubjson:
12263 error_msg +=
"UBJSON";
12266 case input_format_t::bson:
12267 error_msg +=
"BSON";
12270 case input_format_t::bjdata:
12271 error_msg +=
"BJData";
12274 case input_format_t::json:
12286 InputAdapterType ia;
12289 char_int_type current = char_traits<char_type>::eof();
12292 std::size_t chars_read = 0;
12295 const bool is_little_endian = little_endianness();
12298 const input_format_t input_format = input_format_t::json;
12301 json_sax_t* sax =
nullptr;
12304#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12305 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12307#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12308 make_array<bjd_type>( \
12309 bjd_type{'C', "char"}, \
12310 bjd_type{'D', "double"}, \
12311 bjd_type{'I', "int16"}, \
12312 bjd_type{'L', "int64"}, \
12313 bjd_type{'M', "uint64"}, \
12314 bjd_type{'U', "uint8"}, \
12315 bjd_type{'d', "single"}, \
12316 bjd_type{'i', "int8"}, \
12317 bjd_type{'l', "int32"}, \
12318 bjd_type{'m', "uint32"}, \
12319 bjd_type{'u', "uint16"})
12327 using bjd_type = std::pair<char_int_type, string_t>;
12332#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12333#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12336#ifndef JSON_HAS_CPP_17
12337 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12338 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12361#include <functional>
12390enum class parse_event_t : std::uint8_t
12406template<
typename BasicJsonType>
12407using parser_callback_t =
12408 std::function<bool(
int , parse_event_t , BasicJsonType& )>;
12415template<
typename BasicJsonType,
typename InputAdapterType>
12418 using number_integer_t =
typename BasicJsonType::number_integer_t;
12419 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12420 using number_float_t =
typename BasicJsonType::number_float_t;
12421 using string_t =
typename BasicJsonType::string_t;
12422 using lexer_t = lexer<BasicJsonType, InputAdapterType>;
12427 explicit parser(InputAdapterType&& adapter,
12428 parser_callback_t<BasicJsonType> cb =
nullptr,
12429 const bool allow_exceptions_ =
true,
12430 const bool skip_comments =
false)
12431 : callback(
std::move(cb))
12432 , m_lexer(
std::move(adapter), skip_comments)
12433 , allow_exceptions(allow_exceptions_)
12449 void parse(
const bool strict, BasicJsonType& result)
12453 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
12454 sax_parse_internal(&sdp);
12457 if (
strict && (get_token() != token_type::end_of_input))
12459 sdp.parse_error(m_lexer.get_position(),
12460 m_lexer.get_token_string(),
12462 exception_message(token_type::end_of_input,
"value"),
nullptr));
12466 if (sdp.is_errored())
12474 if (result.is_discarded())
12481 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
12482 sax_parse_internal(&sdp);
12485 if (
strict && (get_token() != token_type::end_of_input))
12487 sdp.parse_error(m_lexer.get_position(),
12488 m_lexer.get_token_string(),
12489 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12493 if (sdp.is_errored())
12500 result.assert_invariant();
12509 bool accept(
const bool strict =
true)
12511 json_sax_acceptor<BasicJsonType> sax_acceptor;
12512 return sax_parse(&sax_acceptor,
strict);
12515 template<
typename SAX>
12517 bool sax_parse(SAX* sax, const
bool strict = true)
12519 (
void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
12520 const bool result = sax_parse_internal(sax);
12523 if (result &&
strict && (get_token() != token_type::end_of_input))
12525 return sax->parse_error(m_lexer.get_position(),
12526 m_lexer.get_token_string(),
12527 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12534 template<
typename SAX>
12536 bool sax_parse_internal(SAX* sax)
12540 std::vector<bool> states;
12542 bool skip_to_state_evaluation =
false;
12546 if (!skip_to_state_evaluation)
12549 switch (last_token)
12551 case token_type::begin_object:
12559 if (get_token() == token_type::end_object)
12571 return sax->parse_error(m_lexer.get_position(),
12572 m_lexer.get_token_string(),
12573 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12583 return sax->parse_error(m_lexer.get_position(),
12584 m_lexer.get_token_string(),
12585 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12589 states.push_back(
false);
12596 case token_type::begin_array:
12604 if (get_token() == token_type::end_array)
12614 states.push_back(
true);
12620 case token_type::value_float:
12622 const auto res = m_lexer.get_number_float();
12626 return sax->parse_error(m_lexer.get_position(),
12627 m_lexer.get_token_string(),
12639 case token_type::literal_false:
12648 case token_type::literal_null:
12657 case token_type::literal_true:
12666 case token_type::value_integer:
12675 case token_type::value_string:
12684 case token_type::value_unsigned:
12693 case token_type::parse_error:
12696 return sax->parse_error(m_lexer.get_position(),
12697 m_lexer.get_token_string(),
12698 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12700 case token_type::end_of_input:
12704 return sax->parse_error(m_lexer.get_position(),
12705 m_lexer.get_token_string(),
12707 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
12710 return sax->parse_error(m_lexer.get_position(),
12711 m_lexer.get_token_string(),
12712 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12714 case token_type::uninitialized:
12715 case token_type::end_array:
12716 case token_type::end_object:
12717 case token_type::name_separator:
12718 case token_type::value_separator:
12719 case token_type::literal_or_value:
12722 return sax->parse_error(m_lexer.get_position(),
12723 m_lexer.get_token_string(),
12724 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12730 skip_to_state_evaluation =
false;
12734 if (states.empty())
12743 if (get_token() == token_type::value_separator)
12764 skip_to_state_evaluation =
true;
12768 return sax->parse_error(m_lexer.get_position(),
12769 m_lexer.get_token_string(),
12770 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12776 if (get_token() == token_type::value_separator)
12781 return sax->parse_error(m_lexer.get_position(),
12782 m_lexer.get_token_string(),
12783 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12794 return sax->parse_error(m_lexer.get_position(),
12795 m_lexer.get_token_string(),
12796 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12818 skip_to_state_evaluation =
true;
12822 return sax->parse_error(m_lexer.get_position(),
12823 m_lexer.get_token_string(),
12824 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12829 token_type get_token()
12831 return last_token = m_lexer.scan();
12834 std::string exception_message(
const token_type expected,
const std::string& context)
12836 std::string error_msg =
"syntax error ";
12838 if (!context.empty())
12840 error_msg +=
concat(
"while parsing ", context,
' ');
12845 if (last_token == token_type::parse_error)
12847 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12848 m_lexer.get_token_string(),
'\'');
12855 if (expected != token_type::uninitialized)
12865 const parser_callback_t<BasicJsonType> callback =
nullptr;
12867 token_type last_token = token_type::uninitialized;
12871 const bool allow_exceptions =
true;
12920class primitive_iterator_t
12923 using difference_type = std::ptrdiff_t;
12924 static constexpr difference_type begin_value = 0;
12925 static constexpr difference_type end_value = begin_value + 1;
12929 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12932 constexpr difference_type get_value() const noexcept
12938 void set_begin() noexcept
12940 m_it = begin_value;
12944 void set_end() noexcept
12950 constexpr bool is_begin() const noexcept
12952 return m_it == begin_value;
12956 constexpr bool is_end() const noexcept
12958 return m_it == end_value;
12961 friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
12963 return lhs.m_it == rhs.m_it;
12966 friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
12968 return lhs.m_it < rhs.m_it;
12971 primitive_iterator_t
operator+(difference_type n)
noexcept
12973 auto result = *
this;
12978 friend constexpr difference_type
operator-(primitive_iterator_t lhs, primitive_iterator_t rhs)
noexcept
12980 return lhs.m_it - rhs.m_it;
12983 primitive_iterator_t& operator++() noexcept
12989 primitive_iterator_t operator++(
int)&
noexcept
12991 auto result = *
this;
12996 primitive_iterator_t& operator--() noexcept
13002 primitive_iterator_t operator--(
int)&
noexcept
13004 auto result = *
this;
13009 primitive_iterator_t& operator+=(difference_type n)
noexcept
13015 primitive_iterator_t& operator-=(difference_type n)
noexcept
13061#include <type_traits>
13083template<
typename IteratorType>
class iteration_proxy;
13084template<
typename IteratorType>
class iteration_proxy_value;
13102template<
typename BasicJsonType>
13109 friend BasicJsonType;
13113 using object_t =
typename BasicJsonType::object_t;
13114 using array_t =
typename BasicJsonType::array_t;
13117 "iter_impl only accepts (const) basic_json");
13119 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13120 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
13121 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13136 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13137 typename BasicJsonType::const_pointer,
13138 typename BasicJsonType::pointer>
::type;
13141 typename std::conditional<std::is_const<BasicJsonType>::value,
13142 typename BasicJsonType::const_reference,
13143 typename BasicJsonType::reference>
::type;
13160 switch (m_object->m_data.m_type)
13207 : m_object(other.m_object),
m_it(other.m_it)
13218 if (&other !=
this)
13220 m_object = other.m_object;
13232 : m_object(other.m_object),
m_it(other.m_it)
13243 m_object = other.m_object;
13253 void set_begin() noexcept
13257 switch (m_object->m_data.m_type)
13301 switch (m_object->m_data.m_type)
13340 switch (m_object->m_data.m_type)
13384 switch (m_object->m_data.m_type)
13424 auto result = *
this;
13437 switch (m_object->m_data.m_type)
13475 auto result = *
this;
13488 switch (m_object->m_data.m_type)
13524 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13534 if (m_object ==
nullptr)
13539 switch (m_object->m_data.m_type)
13564 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13583 if (m_object ==
nullptr)
13589 switch (m_object->m_data.m_type)
13616 return !other.operator < (*this);
13645 switch (m_object->m_data.m_type)
13689 auto result = *
this;
13711 auto result = *
this;
13724 switch (m_object->m_data.m_type)
13753 switch (m_object->m_data.m_type)
13787 const typename object_t::key_type&
key()
const
13864template<
typename Base>
13938 auto it = --this->base();
13945 auto it = --this->base();
13946 return it.operator * ();
13966#include <type_traits>
13989 std::is_same<T, void>::value,
14008#include <algorithm>
14036template<
typename RefStringType>
14046 template<
typename T>
14047 struct string_t_helper
14055 using type = StringType;
14060 using string_t =
typename string_t_helper<RefStringType>::type;
14065 : reference_tokens(split(s))
14072 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14076 return detail::concat(a,
'/', detail::escape(b));
14102 reference_tokens.insert(reference_tokens.end(),
14103 ptr.reference_tokens.begin(),
14104 ptr.reference_tokens.end());
14120 return *
this /= std::to_string(array_idx);
14168 reference_tokens.pop_back();
14180 return reference_tokens.back();
14187 reference_tokens.push_back(token);
14194 reference_tokens.push_back(std::move(token));
14201 return reference_tokens.empty();
14215 template<
typename BasicJsonType>
14216 static typename BasicJsonType::size_type array_index(
const string_t& s)
14218 using size_type =
typename BasicJsonType::size_type;
14232 const char* p = s.c_str();
14233 char* p_end =
nullptr;
14235 const unsigned long long res = std::strtoull(p, &p_end, 10);
14245 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14250 return static_cast<size_type
>(res);
14262 result.reference_tokens = {reference_tokens[0]};
14275 template<
typename BasicJsonType>
14276 BasicJsonType& get_and_create(BasicJsonType& j)
const
14282 for (
const auto& reference_token : reference_tokens)
14284 switch (result->type())
14288 if (reference_token ==
"0")
14291 result = &result->operator[](0);
14296 result = &result->operator[](reference_token);
14304 result = &result->operator[](reference_token);
14311 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14355 template<
typename BasicJsonType>
14356 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14358 for (
const auto& reference_token : reference_tokens)
14361 if (ptr->is_null())
14365 std::all_of(reference_token.begin(), reference_token.end(),
14366 [](
const unsigned char x)
14368 return std::isdigit(x);
14372 *ptr = (nums || reference_token ==
"-")
14377 switch (ptr->type())
14382 ptr = &ptr->operator[](reference_token);
14388 if (reference_token ==
"-")
14391 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14396 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14423 template<
typename BasicJsonType>
14424 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14426 for (
const auto& reference_token : reference_tokens)
14428 switch (ptr->type())
14433 ptr = &ptr->at(reference_token);
14443 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14444 ") is out of range"), ptr));
14448 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14481 template<
typename BasicJsonType>
14482 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
14484 for (
const auto& reference_token : reference_tokens)
14486 switch (ptr->type())
14491 ptr = &ptr->operator[](reference_token);
14504 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14530 template<
typename BasicJsonType>
14531 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
14533 for (
const auto& reference_token : reference_tokens)
14535 switch (ptr->type())
14540 ptr = &ptr->at(reference_token);
14550 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14551 ") is out of range"), ptr));
14555 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14579 template<
typename BasicJsonType>
14580 bool contains(
const BasicJsonType* ptr)
const
14582 for (
const auto& reference_token : reference_tokens)
14584 switch (ptr->type())
14588 if (!ptr->contains(reference_token))
14594 ptr = &ptr->operator[](reference_token);
14605 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14617 for (std::size_t i = 1; i < reference_token.size(); i++)
14627 const auto idx = array_index<BasicJsonType>(reference_token);
14628 if (idx >= ptr->size())
14634 ptr = &ptr->operator[](idx);
14668 static std::vector<string_t> split(
const string_t& reference_string)
14670 std::vector<string_t> result;
14673 if (reference_string.empty())
14689 std::size_t slash = reference_string.find_first_of(
'/', 1),
14696 start = (slash == string_t::npos) ? 0 : slash + 1,
14698 slash = reference_string.find_first_of(
'/',
start))
14702 auto reference_token = reference_string.substr(
start, slash -
start);
14705 for (std::size_t pos = reference_token.find_first_of(
'~');
14706 pos != string_t::npos;
14707 pos = reference_token.find_first_of(
'~', pos + 1))
14713 (reference_token[pos + 1] !=
'0' &&
14714 reference_token[pos + 1] !=
'1')))
14721 detail::unescape(reference_token);
14722 result.push_back(reference_token);
14736 template<
typename BasicJsonType>
14737 static void flatten(
const string_t& reference_string,
14738 const BasicJsonType&
value,
14739 BasicJsonType& result)
14741 switch (
value.type())
14745 if (
value.m_data.m_value.array->empty())
14748 result[reference_string] =
nullptr;
14753 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
14755 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
14756 value.m_data.m_value.array->operator[](i), result);
14764 if (
value.m_data.m_value.object->empty())
14767 result[reference_string] =
nullptr;
14772 for (
const auto& element : *
value.m_data.m_value.
object)
14791 result[reference_string] =
value;
14807 template<
typename BasicJsonType>
14808 static BasicJsonType
14809 unflatten(
const BasicJsonType&
value)
14816 BasicJsonType result;
14819 for (
const auto& element : *
value.m_data.m_value.
object)
14830 json_pointer(element.first).get_and_create(result) = element.second;
14840 result.reference_tokens = reference_tokens;
14847 result.reference_tokens = std::move(reference_tokens);
14852#if JSON_HAS_THREE_WAY_COMPARISON
14855 template<
typename RefStringTypeRhs>
14858 return reference_tokens == rhs.reference_tokens;
14870 template<
typename RefStringTypeRhs>
14873 return reference_tokens <=> rhs.reference_tokens;
14878 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14885 template<
typename RefStringTypeLhs,
typename StringType>
14888 const StringType& rhs);
14892 template<
typename RefStringTypeRhs,
typename StringType>
14894 friend bool operator==(
const StringType& lhs,
14899 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14906 template<
typename RefStringTypeLhs,
typename StringType>
14909 const StringType& rhs);
14913 template<
typename RefStringTypeRhs,
typename StringType>
14915 friend bool operator!=(
const StringType& lhs,
14919 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14927 std::vector<string_t> reference_tokens;
14930#if !JSON_HAS_THREE_WAY_COMPARISON
14932template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14936 return lhs.reference_tokens == rhs.reference_tokens;
14939template<
typename RefStringTypeLhs,
14943 const StringType& rhs)
14948template<
typename RefStringTypeRhs,
14951inline
bool operator==(const StringType& lhs,
14957template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14961 return !(lhs == rhs);
14964template<
typename RefStringTypeLhs,
14968 const StringType& rhs)
14970 return !(lhs == rhs);
14973template<
typename RefStringTypeRhs,
14976inline
bool operator!=(const StringType& lhs,
14979 return !(lhs == rhs);
14982template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14986 return lhs.reference_tokens < rhs.reference_tokens;
15003#include <initializer_list>
15015template<
typename BasicJsonType>
15026 : value_ref(&
value)
15030 : owned_value(init)
15037 : owned_value(
std::forward<Args>(args)...)
15049 if (value_ref ==
nullptr)
15051 return std::move(owned_value);
15058 return value_ref ? *value_ref : owned_value;
15095#include <algorithm>
15121#include <algorithm>
15141template<
typename CharType>
struct output_adapter_protocol
15143 virtual void write_character(CharType c) = 0;
15144 virtual void write_characters(
const CharType* s, std::size_t
length) = 0;
15145 virtual ~output_adapter_protocol() =
default;
15147 output_adapter_protocol() =
default;
15148 output_adapter_protocol(
const output_adapter_protocol&) =
default;
15149 output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
15150 output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
15151 output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
15155template<typename CharType>
15156using output_adapter_t =
std::shared_ptr<output_adapter_protocol<CharType>>;
15159template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15160class output_vector_adapter : public output_adapter_protocol<CharType>
15163 explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept
15167 void write_character(CharType c)
override
15173 void write_characters(const CharType* s,
std::
size_t length)
override
15179 std::vector<CharType, AllocatorType>&
v;
15184template<
typename CharType>
15185class output_stream_adapter :
public output_adapter_protocol<CharType>
15188 explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
15192 void write_character(CharType c)
override
15198 void write_characters(const CharType* s,
std::
size_t length)
override
15200 stream.write(s,
static_cast<std::streamsize
>(
length));
15204 std::basic_ostream<CharType>& stream;
15209template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15210class output_string_adapter :
public output_adapter_protocol<CharType>
15213 explicit output_string_adapter(StringType& s) noexcept
15217 void write_character(CharType c)
override
15223 void write_characters(const CharType* s,
std::
size_t length)
override
15232template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15233class output_adapter
15236 template<
typename AllocatorType = std::allocator<CharType>>
15237 output_adapter(std::vector<CharType, AllocatorType>& vec)
15238 : oa(
std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
15241 output_adapter(std::basic_ostream<CharType>& s)
15242 : oa(
std::make_shared<output_stream_adapter<CharType>>(s)) {}
15245 output_adapter(StringType& s)
15246 : oa(
std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
15248 operator output_adapter_t<CharType>()
15254 output_adapter_t<CharType> oa =
nullptr;
15274template<
typename BasicJsonType,
typename CharType>
15277 using string_t =
typename BasicJsonType::string_t;
15278 using binary_t =
typename BasicJsonType::binary_t;
15279 using number_float_t =
typename BasicJsonType::number_float_t;
15287 explicit binary_writer(output_adapter_t<CharType> adapter) : oa(
std::move(adapter))
15296 void write_bson(
const BasicJsonType& j)
15300 case value_t::object:
15302 write_bson_object(*j.m_data.m_value.object);
15306 case value_t::null:
15307 case value_t::array:
15308 case value_t::string:
15309 case value_t::boolean:
15310 case value_t::number_integer:
15311 case value_t::number_unsigned:
15312 case value_t::number_float:
15313 case value_t::binary:
15314 case value_t::discarded:
15317 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15325 void write_cbor(
const BasicJsonType& j)
15329 case value_t::null:
15331 oa->write_character(to_char_type(0xF6));
15335 case value_t::boolean:
15337 oa->write_character(j.m_data.m_value.boolean
15338 ? to_char_type(0xF5)
15339 : to_char_type(0xF4));
15343 case value_t::number_integer:
15345 if (j.m_data.m_value.number_integer >= 0)
15350 if (j.m_data.m_value.number_integer <= 0x17)
15352 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15354 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15356 oa->write_character(to_char_type(0x18));
15357 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15359 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15361 oa->write_character(to_char_type(0x19));
15362 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15364 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15366 oa->write_character(to_char_type(0x1A));
15367 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15371 oa->write_character(to_char_type(0x1B));
15372 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15379 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15380 if (j.m_data.m_value.number_integer >= -24)
15382 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15384 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15386 oa->write_character(to_char_type(0x38));
15387 write_number(
static_cast<std::uint8_t
>(positive_number));
15389 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15391 oa->write_character(to_char_type(0x39));
15392 write_number(
static_cast<std::uint16_t
>(positive_number));
15394 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15396 oa->write_character(to_char_type(0x3A));
15397 write_number(
static_cast<std::uint32_t
>(positive_number));
15401 oa->write_character(to_char_type(0x3B));
15402 write_number(
static_cast<std::uint64_t
>(positive_number));
15408 case value_t::number_unsigned:
15410 if (j.m_data.m_value.number_unsigned <= 0x17)
15412 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15414 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15416 oa->write_character(to_char_type(0x18));
15417 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15419 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15421 oa->write_character(to_char_type(0x19));
15422 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15424 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15426 oa->write_character(to_char_type(0x1A));
15427 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15431 oa->write_character(to_char_type(0x1B));
15432 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
15437 case value_t::number_float:
15439 if (std::isnan(j.m_data.m_value.number_float))
15442 oa->write_character(to_char_type(0xF9));
15443 oa->write_character(to_char_type(0x7E));
15444 oa->write_character(to_char_type(0x00));
15446 else if (std::isinf(j.m_data.m_value.number_float))
15449 oa->write_character(to_char_type(0xf9));
15450 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15451 oa->write_character(to_char_type(0x00));
15455 write_compact_float(j.m_data.m_value.number_float, detail::input_format_t::cbor);
15460 case value_t::string:
15463 const auto N = j.m_data.m_value.string->size();
15466 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15468 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15470 oa->write_character(to_char_type(0x78));
15471 write_number(
static_cast<std::uint8_t
>(N));
15473 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15475 oa->write_character(to_char_type(0x79));
15476 write_number(
static_cast<std::uint16_t
>(N));
15478 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15480 oa->write_character(to_char_type(0x7A));
15481 write_number(
static_cast<std::uint32_t
>(N));
15484 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15486 oa->write_character(to_char_type(0x7B));
15487 write_number(
static_cast<std::uint64_t
>(N));
15492 oa->write_characters(
15493 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15494 j.m_data.m_value.string->size());
15498 case value_t::array:
15501 const auto N = j.m_data.m_value.array->size();
15504 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15506 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15508 oa->write_character(to_char_type(0x98));
15509 write_number(
static_cast<std::uint8_t
>(N));
15511 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15513 oa->write_character(to_char_type(0x99));
15514 write_number(
static_cast<std::uint16_t
>(N));
15516 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15518 oa->write_character(to_char_type(0x9A));
15519 write_number(
static_cast<std::uint32_t
>(N));
15522 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15524 oa->write_character(to_char_type(0x9B));
15525 write_number(
static_cast<std::uint64_t
>(N));
15530 for (
const auto& el : *j.m_data.m_value.
array)
15537 case value_t::binary:
15539 if (j.m_data.m_value.binary->has_subtype())
15541 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15543 write_number(
static_cast<std::uint8_t
>(0xd8));
15544 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
15546 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15548 write_number(
static_cast<std::uint8_t
>(0xd9));
15549 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
15551 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15553 write_number(
static_cast<std::uint8_t
>(0xda));
15554 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
15556 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15558 write_number(
static_cast<std::uint8_t
>(0xdb));
15559 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
15564 const auto N = j.m_data.m_value.binary->size();
15567 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15569 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15571 oa->write_character(to_char_type(0x58));
15572 write_number(
static_cast<std::uint8_t
>(N));
15574 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15576 oa->write_character(to_char_type(0x59));
15577 write_number(
static_cast<std::uint16_t
>(N));
15579 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15581 oa->write_character(to_char_type(0x5A));
15582 write_number(
static_cast<std::uint32_t
>(N));
15585 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15587 oa->write_character(to_char_type(0x5B));
15588 write_number(
static_cast<std::uint64_t
>(N));
15593 oa->write_characters(
15594 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15600 case value_t::object:
15603 const auto N = j.m_data.m_value.object->size();
15606 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15608 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15610 oa->write_character(to_char_type(0xB8));
15611 write_number(
static_cast<std::uint8_t
>(N));
15613 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15615 oa->write_character(to_char_type(0xB9));
15616 write_number(
static_cast<std::uint16_t
>(N));
15618 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15620 oa->write_character(to_char_type(0xBA));
15621 write_number(
static_cast<std::uint32_t
>(N));
15624 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15626 oa->write_character(to_char_type(0xBB));
15627 write_number(
static_cast<std::uint64_t
>(N));
15632 for (
const auto& el : *j.m_data.m_value.
object)
15634 write_cbor(el.first);
15635 write_cbor(el.second);
15640 case value_t::discarded:
15649 void write_msgpack(
const BasicJsonType& j)
15653 case value_t::null:
15655 oa->write_character(to_char_type(0xC0));
15659 case value_t::boolean:
15661 oa->write_character(j.m_data.m_value.boolean
15662 ? to_char_type(0xC3)
15663 : to_char_type(0xC2));
15667 case value_t::number_integer:
15669 if (j.m_data.m_value.number_integer >= 0)
15674 if (j.m_data.m_value.number_unsigned < 128)
15677 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15679 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15682 oa->write_character(to_char_type(0xCC));
15683 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15685 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15688 oa->write_character(to_char_type(0xCD));
15689 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15691 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15694 oa->write_character(to_char_type(0xCE));
15695 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15697 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15700 oa->write_character(to_char_type(0xCF));
15701 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15706 if (j.m_data.m_value.number_integer >= -32)
15709 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15711 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15712 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15715 oa->write_character(to_char_type(0xD0));
15716 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15718 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15719 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15722 oa->write_character(to_char_type(0xD1));
15723 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
15725 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15726 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15729 oa->write_character(to_char_type(0xD2));
15730 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
15732 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15733 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15736 oa->write_character(to_char_type(0xD3));
15737 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
15743 case value_t::number_unsigned:
15745 if (j.m_data.m_value.number_unsigned < 128)
15748 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15750 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15753 oa->write_character(to_char_type(0xCC));
15754 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15756 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15759 oa->write_character(to_char_type(0xCD));
15760 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15762 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15765 oa->write_character(to_char_type(0xCE));
15766 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15768 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15771 oa->write_character(to_char_type(0xCF));
15772 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15777 case value_t::number_float:
15779 write_compact_float(j.m_data.m_value.number_float, detail::input_format_t::msgpack);
15783 case value_t::string:
15786 const auto N = j.m_data.m_value.string->size();
15790 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15792 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15795 oa->write_character(to_char_type(0xD9));
15796 write_number(
static_cast<std::uint8_t
>(N));
15798 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15801 oa->write_character(to_char_type(0xDA));
15802 write_number(
static_cast<std::uint16_t
>(N));
15804 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15807 oa->write_character(to_char_type(0xDB));
15808 write_number(
static_cast<std::uint32_t
>(N));
15812 oa->write_characters(
15813 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15814 j.m_data.m_value.string->size());
15818 case value_t::array:
15821 const auto N = j.m_data.m_value.array->size();
15825 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15827 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15830 oa->write_character(to_char_type(0xDC));
15831 write_number(
static_cast<std::uint16_t
>(N));
15833 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15836 oa->write_character(to_char_type(0xDD));
15837 write_number(
static_cast<std::uint32_t
>(N));
15841 for (
const auto& el : *j.m_data.m_value.
array)
15848 case value_t::binary:
15852 const bool use_ext = j.m_data.m_value.binary->has_subtype();
15855 const auto N = j.m_data.m_value.binary->size();
15856 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15858 std::uint8_t output_type{};
15865 output_type = 0xD4;
15868 output_type = 0xD5;
15871 output_type = 0xD6;
15874 output_type = 0xD7;
15877 output_type = 0xD8;
15880 output_type = 0xC7;
15888 output_type = 0xC4;
15892 oa->write_character(to_char_type(output_type));
15895 write_number(
static_cast<std::uint8_t
>(N));
15898 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15900 const std::uint8_t output_type = use_ext
15904 oa->write_character(to_char_type(output_type));
15905 write_number(
static_cast<std::uint16_t
>(N));
15907 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15909 const std::uint8_t output_type = use_ext
15913 oa->write_character(to_char_type(output_type));
15914 write_number(
static_cast<std::uint32_t
>(N));
15920 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
15924 oa->write_characters(
15925 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15931 case value_t::object:
15934 const auto N = j.m_data.m_value.object->size();
15938 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15940 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15943 oa->write_character(to_char_type(0xDE));
15944 write_number(
static_cast<std::uint16_t
>(N));
15946 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15949 oa->write_character(to_char_type(0xDF));
15950 write_number(
static_cast<std::uint32_t
>(N));
15954 for (
const auto& el : *j.m_data.m_value.
object)
15956 write_msgpack(el.first);
15957 write_msgpack(el.second);
15962 case value_t::discarded:
15975 void write_ubjson(
const BasicJsonType& j,
const bool use_count,
15976 const bool use_type,
const bool add_prefix =
true,
15977 const bool use_bjdata =
false)
15981 case value_t::null:
15985 oa->write_character(to_char_type(
'Z'));
15990 case value_t::boolean:
15994 oa->write_character(j.m_data.m_value.boolean
15995 ? to_char_type(
'T')
15996 : to_char_type(
'F'));
16001 case value_t::number_integer:
16003 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16007 case value_t::number_unsigned:
16009 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16013 case value_t::number_float:
16015 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16019 case value_t::string:
16023 oa->write_character(to_char_type(
'S'));
16025 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16026 oa->write_characters(
16027 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16028 j.m_data.m_value.string->size());
16032 case value_t::array:
16036 oa->write_character(to_char_type(
'['));
16039 bool prefix_required =
true;
16040 if (use_type && !j.m_data.m_value.array->empty())
16043 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16044 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16045 [
this, first_prefix, use_bjdata](
const BasicJsonType &
v)
16047 return ubjson_prefix(v, use_bjdata) == first_prefix;
16050 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16052 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16054 prefix_required =
false;
16055 oa->write_character(to_char_type(
'$'));
16056 oa->write_character(first_prefix);
16062 oa->write_character(to_char_type(
'#'));
16063 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16066 for (
const auto& el : *j.m_data.m_value.
array)
16068 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
16073 oa->write_character(to_char_type(
']'));
16079 case value_t::binary:
16083 oa->write_character(to_char_type(
'['));
16086 if (use_type && !j.m_data.m_value.binary->empty())
16089 oa->write_character(to_char_type(
'$'));
16090 oa->write_character(
'U');
16095 oa->write_character(to_char_type(
'#'));
16096 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16101 oa->write_characters(
16102 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16103 j.m_data.m_value.binary->size());
16107 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16109 oa->write_character(to_char_type(
'U'));
16110 oa->write_character(j.m_data.m_value.binary->data()[i]);
16116 oa->write_character(to_char_type(
']'));
16122 case value_t::object:
16124 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
16126 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type))
16134 oa->write_character(to_char_type(
'{'));
16137 bool prefix_required =
true;
16138 if (use_type && !j.m_data.m_value.object->empty())
16141 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16142 const bool same_prefix = std::all_of(j.begin(), j.end(),
16143 [
this, first_prefix, use_bjdata](
const BasicJsonType &
v)
16145 return ubjson_prefix(v, use_bjdata) == first_prefix;
16148 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16150 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16152 prefix_required =
false;
16153 oa->write_character(to_char_type(
'$'));
16154 oa->write_character(first_prefix);
16160 oa->write_character(to_char_type(
'#'));
16161 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16164 for (
const auto& el : *j.m_data.m_value.
object)
16166 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16167 oa->write_characters(
16168 reinterpret_cast<const CharType*
>(el.first.c_str()),
16170 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
16175 oa->write_character(to_char_type(
'}'));
16181 case value_t::discarded:
16196 static std::size_t calc_bson_entry_header_size(
const string_t&
name,
const BasicJsonType& j)
16198 const auto it =
name.find(
static_cast<typename string_t::value_type
>(0));
16201 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
16202 static_cast<void>(j);
16205 return 1ul +
name.size() + 1u;
16211 void write_bson_entry_header(
const string_t&
name,
16212 const std::uint8_t element_type)
16214 oa->write_character(to_char_type(element_type));
16215 oa->write_characters(
16216 reinterpret_cast<const CharType*
>(
name.c_str()),
16223 void write_bson_boolean(
const string_t&
name,
16226 write_bson_entry_header(
name, 0x08);
16227 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
16233 void write_bson_double(
const string_t&
name,
16234 const double value)
16236 write_bson_entry_header(
name, 0x01);
16237 write_number<double>(
value,
true);
16243 static std::size_t calc_bson_string_size(
const string_t&
value)
16245 return sizeof(std::int32_t) +
value.size() + 1ul;
16251 void write_bson_string(
const string_t&
name,
16252 const string_t&
value)
16254 write_bson_entry_header(
name, 0x02);
16256 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16257 oa->write_characters(
16258 reinterpret_cast<const CharType*
>(
value.c_str()),
16265 void write_bson_null(
const string_t&
name)
16267 write_bson_entry_header(
name, 0x0A);
16273 static std::size_t calc_bson_integer_size(
const std::int64_t
value)
16275 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
16276 ?
sizeof(std::int32_t)
16277 :
sizeof(std::int64_t);
16283 void write_bson_integer(
const string_t&
name,
16284 const std::int64_t
value)
16286 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
16288 write_bson_entry_header(
name, 0x10);
16289 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
16293 write_bson_entry_header(
name, 0x12);
16294 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
16301 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t
value)
noexcept
16303 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16304 ?
sizeof(std::int32_t)
16311 void write_bson_unsigned(
const string_t&
name,
16312 const BasicJsonType& j)
16314 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16316 write_bson_entry_header(
name, 0x10 );
16317 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16319 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16321 write_bson_entry_header(
name, 0x12 );
16322 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16326 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_data.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16333 void write_bson_object_entry(
const string_t&
name,
16334 const typename BasicJsonType::object_t&
value)
16336 write_bson_entry_header(
name, 0x03);
16337 write_bson_object(
value);
16343 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t&
value)
16345 std::size_t array_index = 0ul;
16347 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16349 return result + calc_bson_element_size(std::to_string(array_index++), el);
16352 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16358 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t&
value)
16360 return sizeof(std::int32_t) +
value.size() + 1ul;
16366 void write_bson_array(
const string_t&
name,
16367 const typename BasicJsonType::array_t&
value)
16369 write_bson_entry_header(
name, 0x04);
16370 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
16372 std::size_t array_index = 0ul;
16374 for (
const auto& el :
value)
16376 write_bson_element(std::to_string(array_index++), el);
16379 oa->write_character(to_char_type(0x00));
16385 void write_bson_binary(
const string_t&
name,
16386 const binary_t&
value)
16388 write_bson_entry_header(
name, 0x05);
16390 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16391 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) : static_cast<
std::
uint8_t>(0x00));
16393 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16400 static std::size_t calc_bson_element_size(
const string_t&
name,
16401 const BasicJsonType& j)
16403 const auto header_size = calc_bson_entry_header_size(
name, j);
16406 case value_t::object:
16407 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16409 case value_t::array:
16410 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16412 case value_t::binary:
16413 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16415 case value_t::boolean:
16416 return header_size + 1ul;
16418 case value_t::number_float:
16419 return header_size + 8ul;
16421 case value_t::number_integer:
16422 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16424 case value_t::number_unsigned:
16425 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16427 case value_t::string:
16428 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16430 case value_t::null:
16431 return header_size + 0ul;
16434 case value_t::discarded:
16448 void write_bson_element(
const string_t&
name,
16449 const BasicJsonType& j)
16453 case value_t::object:
16454 return write_bson_object_entry(
name, *j.m_data.m_value.object);
16456 case value_t::array:
16457 return write_bson_array(
name, *j.m_data.m_value.array);
16459 case value_t::binary:
16460 return write_bson_binary(
name, *j.m_data.m_value.binary);
16462 case value_t::boolean:
16463 return write_bson_boolean(
name, j.m_data.m_value.boolean);
16465 case value_t::number_float:
16466 return write_bson_double(
name, j.m_data.m_value.number_float);
16468 case value_t::number_integer:
16469 return write_bson_integer(
name, j.m_data.m_value.number_integer);
16471 case value_t::number_unsigned:
16472 return write_bson_unsigned(
name, j);
16474 case value_t::string:
16475 return write_bson_string(
name, *j.m_data.m_value.string);
16477 case value_t::null:
16478 return write_bson_null(
name);
16481 case value_t::discarded:
16495 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t&
value)
16497 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
16498 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16500 return result += calc_bson_element_size(el.first, el.second);
16503 return sizeof(std::int32_t) + document_size + 1ul;
16510 void write_bson_object(
const typename BasicJsonType::object_t&
value)
16512 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
16514 for (
const auto& el :
value)
16516 write_bson_element(el.first, el.second);
16519 oa->write_character(to_char_type(0x00));
16526 static constexpr CharType get_cbor_float_prefix(
float )
16528 return to_char_type(0xFA);
16531 static constexpr CharType get_cbor_float_prefix(
double )
16533 return to_char_type(0xFB);
16540 static constexpr CharType get_msgpack_float_prefix(
float )
16542 return to_char_type(0xCA);
16545 static constexpr CharType get_msgpack_float_prefix(
double )
16547 return to_char_type(0xCB);
16555 template<
typename NumberType,
typename std::enable_if<
16556 std::is_floating_point<NumberType>::value,
int>
::type = 0>
16557 void write_number_with_ubjson_prefix(
const NumberType n,
16558 const bool add_prefix,
16559 const bool use_bjdata)
16563 oa->write_character(get_ubjson_float_prefix(n));
16565 write_number(n, use_bjdata);
16569 template<
typename NumberType,
typename std::enable_if<
16570 std::is_unsigned<NumberType>::value,
int>
::type = 0>
16571 void write_number_with_ubjson_prefix(
const NumberType n,
16572 const bool add_prefix,
16573 const bool use_bjdata)
16575 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16579 oa->write_character(to_char_type(
'i'));
16581 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16583 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16587 oa->write_character(to_char_type(
'U'));
16589 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16591 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16595 oa->write_character(to_char_type(
'I'));
16597 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16599 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint16_t>::max)()))
16603 oa->write_character(to_char_type(
'u'));
16605 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16607 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16611 oa->write_character(to_char_type(
'l'));
16613 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16615 else if (use_bjdata && n <=
static_cast<uint64_t>((std::numeric_limits<uint32_t>::max)()))
16619 oa->write_character(to_char_type(
'm'));
16621 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16623 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16627 oa->write_character(to_char_type(
'L'));
16629 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16631 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16635 oa->write_character(to_char_type(
'M'));
16637 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16643 oa->write_character(to_char_type(
'H'));
16646 const auto number = BasicJsonType(n).dump();
16647 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16648 for (std::size_t i = 0; i < number.size(); ++i)
16650 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16656 template <
typename NumberType,
typename std::enable_if <
16657 std::is_signed<NumberType>::value&&
16658 !std::is_floating_point<NumberType>::value,
int >
::type = 0 >
16659 void write_number_with_ubjson_prefix(
const NumberType n,
16660 const bool add_prefix,
16661 const bool use_bjdata)
16663 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16667 oa->write_character(to_char_type(
'i'));
16669 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16671 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16675 oa->write_character(to_char_type(
'U'));
16677 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16679 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16683 oa->write_character(to_char_type(
'I'));
16685 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16687 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
16691 oa->write_character(to_char_type(
'u'));
16693 write_number(
static_cast<uint16_t>(n), use_bjdata);
16695 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16699 oa->write_character(to_char_type(
'l'));
16701 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16703 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
16707 oa->write_character(to_char_type(
'm'));
16709 write_number(
static_cast<uint32_t>(n), use_bjdata);
16711 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16715 oa->write_character(to_char_type(
'L'));
16717 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16724 oa->write_character(to_char_type(
'H'));
16727 const auto number = BasicJsonType(n).dump();
16728 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16729 for (std::size_t i = 0; i < number.size(); ++i)
16731 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16740 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16744 case value_t::null:
16747 case value_t::boolean:
16748 return j.m_data.m_value.boolean ?
'T' :
'F';
16750 case value_t::number_integer:
16752 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16756 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16760 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16764 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16768 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16772 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16776 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16784 case value_t::number_unsigned:
16786 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16790 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16794 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16798 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16802 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16806 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16810 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16814 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16822 case value_t::number_float:
16823 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
16825 case value_t::string:
16828 case value_t::array:
16829 case value_t::binary:
16832 case value_t::object:
16835 case value_t::discarded:
16841 static constexpr CharType get_ubjson_float_prefix(
float )
16846 static constexpr CharType get_ubjson_float_prefix(
double )
16854 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t&
value,
const bool use_count,
const bool use_type)
16856 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16857 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16860 string_t key =
"_ArrayType_";
16861 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
16862 if (it == bjdtype.end())
16866 CharType dtype = it->second;
16868 key =
"_ArraySize_";
16869 std::size_t len = (
value.at(key).empty() ? 0 : 1);
16870 for (
const auto& el :
value.at(key))
16872 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
16875 key =
"_ArrayData_";
16876 if (
value.at(key).size() != len)
16881 oa->write_character(
'[');
16882 oa->write_character(
'$');
16883 oa->write_character(dtype);
16884 oa->write_character(
'#');
16886 key =
"_ArraySize_";
16887 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
16889 key =
"_ArrayData_";
16890 if (dtype ==
'U' || dtype ==
'C')
16892 for (
const auto& el :
value.at(key))
16894 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
16897 else if (dtype ==
'i')
16899 for (
const auto& el :
value.at(key))
16901 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
16904 else if (dtype ==
'u')
16906 for (
const auto& el :
value.at(key))
16908 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
16911 else if (dtype ==
'I')
16913 for (
const auto& el :
value.at(key))
16915 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
16918 else if (dtype ==
'm')
16920 for (
const auto& el :
value.at(key))
16922 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
16925 else if (dtype ==
'l')
16927 for (
const auto& el :
value.at(key))
16929 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
16932 else if (dtype ==
'M')
16934 for (
const auto& el :
value.at(key))
16936 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
16939 else if (dtype ==
'L')
16941 for (
const auto& el :
value.at(key))
16943 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
16946 else if (dtype ==
'd')
16948 for (
const auto& el :
value.at(key))
16950 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
16953 else if (dtype ==
'D')
16955 for (
const auto& el :
value.at(key))
16957 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
16980 template<
typename NumberType>
16981 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
16984 std::array<CharType,
sizeof(NumberType)> vec{};
16985 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16988 if (is_little_endian != OutputIsLittleEndian)
16991 std::reverse(vec.begin(), vec.end());
16994 oa->write_characters(vec.data(),
sizeof(NumberType));
16997 void write_compact_float(
const number_float_t n, detail::input_format_t
format)
17000#pragma GCC diagnostic push
17001#pragma GCC diagnostic ignored "-Wfloat-equal"
17003 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17004 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17005 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
17007 oa->write_character(
format == detail::input_format_t::cbor
17008 ? get_cbor_float_prefix(
static_cast<float>(n))
17009 : get_msgpack_float_prefix(static_cast<float>(n)));
17010 write_number(
static_cast<float>(n));
17014 oa->write_character(
format == detail::input_format_t::cbor
17015 ? get_cbor_float_prefix(n)
17016 : get_msgpack_float_prefix(n));
17020#pragma GCC diagnostic pop
17029 template <
typename C = CharType,
17030 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17031 static constexpr CharType to_char_type(std::uint8_t
x)
noexcept
17033 return *
reinterpret_cast<char*
>(&
x);
17036 template <
typename C = CharType,
17037 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17038 static CharType to_char_type(std::uint8_t
x)
noexcept
17040 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17041 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17043 std::memcpy(&result, &
x,
sizeof(
x));
17047 template<
typename C = CharType,
17048 enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
17049 static constexpr CharType to_char_type(std::uint8_t
x)
noexcept
17054 template <
typename InputCharType,
typename C = CharType,
17056 std::is_signed<C>::value &&
17057 std::is_signed<char>::value &&
17058 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
17060 static constexpr CharType to_char_type(InputCharType
x)
noexcept
17067 const bool is_little_endian = little_endianness();
17070 output_adapter_t<CharType> oa =
nullptr;
17090#include <algorithm>
17100#include <type_traits>
17120#include <type_traits>
17151template<
typename Target,
typename Source>
17152Target reinterpret_bits(
const Source
source)
17154 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17157 std::memcpy(&target, &
source,
sizeof(Source));
17163 static constexpr int kPrecision = 64;
17165 std::uint64_t
f = 0;
17168 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_), e(e_) {}
17174 static diyfp sub(
const diyfp&
x,
const diyfp&
y)
noexcept
17179 return {
x.f -
y.f,
x.e};
17186 static diyfp mul(
const diyfp&
x,
const diyfp&
y)
noexcept
17188 static_assert(kPrecision == 64,
"internal error");
17213 const std::uint64_t u_lo =
x.f & 0xFFFFFFFFu;
17214 const std::uint64_t u_hi =
x.f >> 32u;
17215 const std::uint64_t v_lo =
y.f & 0xFFFFFFFFu;
17216 const std::uint64_t v_hi =
y.f >> 32u;
17218 const std::uint64_t p0 = u_lo * v_lo;
17219 const std::uint64_t p1 = u_lo * v_hi;
17220 const std::uint64_t p2 = u_hi * v_lo;
17221 const std::uint64_t p3 = u_hi * v_hi;
17223 const std::uint64_t p0_hi = p0 >> 32u;
17224 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17225 const std::uint64_t p1_hi = p1 >> 32u;
17226 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17227 const std::uint64_t p2_hi = p2 >> 32u;
17229 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17240 Q += std::uint64_t{1} << (64u - 32u - 1u);
17242 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17244 return {h,
x.e +
y.e + 64};
17251 static diyfp normalize(diyfp
x)
noexcept
17255 while ((
x.f >> 63u) == 0)
17268 static diyfp normalize_to(
const diyfp&
x,
const int target_exponent)
noexcept
17270 const int delta =
x.e - target_exponent;
17275 return {
x.f << delta, target_exponent};
17292template<
typename FloatType>
17293boundaries compute_boundaries(FloatType
value)
17305 static_assert(std::numeric_limits<FloatType>::is_iec559,
17306 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17308 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17309 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17310 constexpr int kMinExp = 1 - kBias;
17311 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17313 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17315 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
17316 const std::uint64_t E = bits >> (kPrecision - 1);
17317 const std::uint64_t F = bits & (kHiddenBit - 1);
17319 const bool is_denormal = E == 0;
17320 const diyfp
v = is_denormal
17321 ? diyfp(F, kMinExp)
17322 : diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17345 const bool lower_boundary_is_closer = F == 0 && E > 1;
17346 const diyfp m_plus = diyfp((2 *
v.f) + 1,
v.e - 1);
17347 const diyfp m_minus = lower_boundary_is_closer
17348 ? diyfp((4 *
v.f) - 1,
v.e - 2)
17349 : diyfp((2 *
v.f) - 1,
v.e - 1);
17352 const diyfp w_plus = diyfp::normalize(m_plus);
17355 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
17357 return {diyfp::normalize(
v), w_minus, w_plus};
17415constexpr int kAlpha = -60;
17416constexpr int kGamma = -32;
17432inline cached_power get_cached_power_for_binary_exponent(
int e)
17484 constexpr int kCachedPowersMinDecExp = -300;
17485 constexpr int kCachedPowersDecStep = 8;
17487 static constexpr std::array<cached_power, 79> kCachedPowers =
17490 { 0xAB70FE17C79AC6CA, -1060, -300 },
17491 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17492 { 0xBE5691EF416BD60C, -1007, -284 },
17493 { 0x8DD01FAD907FFC3C, -980, -276 },
17494 { 0xD3515C2831559A83, -954, -268 },
17495 { 0x9D71AC8FADA6C9B5, -927, -260 },
17496 { 0xEA9C227723EE8BCB, -901, -252 },
17497 { 0xAECC49914078536D, -874, -244 },
17498 { 0x823C12795DB6CE57, -847, -236 },
17499 { 0xC21094364DFB5637, -821, -228 },
17500 { 0x9096EA6F3848984F, -794, -220 },
17501 { 0xD77485CB25823AC7, -768, -212 },
17502 { 0xA086CFCD97BF97F4, -741, -204 },
17503 { 0xEF340A98172AACE5, -715, -196 },
17504 { 0xB23867FB2A35B28E, -688, -188 },
17505 { 0x84C8D4DFD2C63F3B, -661, -180 },
17506 { 0xC5DD44271AD3CDBA, -635, -172 },
17507 { 0x936B9FCEBB25C996, -608, -164 },
17508 { 0xDBAC6C247D62A584, -582, -156 },
17509 { 0xA3AB66580D5FDAF6, -555, -148 },
17510 { 0xF3E2F893DEC3F126, -529, -140 },
17511 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17512 { 0x87625F056C7C4A8B, -475, -124 },
17513 { 0xC9BCFF6034C13053, -449, -116 },
17514 { 0x964E858C91BA2655, -422, -108 },
17515 { 0xDFF9772470297EBD, -396, -100 },
17516 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17517 { 0xF8A95FCF88747D94, -343, -84 },
17518 { 0xB94470938FA89BCF, -316, -76 },
17519 { 0x8A08F0F8BF0F156B, -289, -68 },
17520 { 0xCDB02555653131B6, -263, -60 },
17521 { 0x993FE2C6D07B7FAC, -236, -52 },
17522 { 0xE45C10C42A2B3B06, -210, -44 },
17523 { 0xAA242499697392D3, -183, -36 },
17524 { 0xFD87B5F28300CA0E, -157, -28 },
17525 { 0xBCE5086492111AEB, -130, -20 },
17526 { 0x8CBCCC096F5088CC, -103, -12 },
17527 { 0xD1B71758E219652C, -77, -4 },
17528 { 0x9C40000000000000, -50, 4 },
17529 { 0xE8D4A51000000000, -24, 12 },
17530 { 0xAD78EBC5AC620000, 3, 20 },
17531 { 0x813F3978F8940984, 30, 28 },
17532 { 0xC097CE7BC90715B3, 56, 36 },
17533 { 0x8F7E32CE7BEA5C70, 83, 44 },
17534 { 0xD5D238A4ABE98068, 109, 52 },
17535 { 0x9F4F2726179A2245, 136, 60 },
17536 { 0xED63A231D4C4FB27, 162, 68 },
17537 { 0xB0DE65388CC8ADA8, 189, 76 },
17538 { 0x83C7088E1AAB65DB, 216, 84 },
17539 { 0xC45D1DF942711D9A, 242, 92 },
17540 { 0x924D692CA61BE758, 269, 100 },
17541 { 0xDA01EE641A708DEA, 295, 108 },
17542 { 0xA26DA3999AEF774A, 322, 116 },
17543 { 0xF209787BB47D6B85, 348, 124 },
17544 { 0xB454E4A179DD1877, 375, 132 },
17545 { 0x865B86925B9BC5C2, 402, 140 },
17546 { 0xC83553C5C8965D3D, 428, 148 },
17547 { 0x952AB45CFA97A0B3, 455, 156 },
17548 { 0xDE469FBD99A05FE3, 481, 164 },
17549 { 0xA59BC234DB398C25, 508, 172 },
17550 { 0xF6C69A72A3989F5C, 534, 180 },
17551 { 0xB7DCBF5354E9BECE, 561, 188 },
17552 { 0x88FCF317F22241E2, 588, 196 },
17553 { 0xCC20CE9BD35C78A5, 614, 204 },
17554 { 0x98165AF37B2153DF, 641, 212 },
17555 { 0xE2A0B5DC971F303A, 667, 220 },
17556 { 0xA8D9D1535CE3B396, 694, 228 },
17557 { 0xFB9B7CD9A4A7443C, 720, 236 },
17558 { 0xBB764C4CA7A44410, 747, 244 },
17559 { 0x8BAB8EEFB6409C1A, 774, 252 },
17560 { 0xD01FEF10A657842C, 800, 260 },
17561 { 0x9B10A4E5E9913129, 827, 268 },
17562 { 0xE7109BFBA19C0C9D, 853, 276 },
17563 { 0xAC2820D9623BF429, 880, 284 },
17564 { 0x80444B5E7AA7CF85, 907, 292 },
17565 { 0xBF21E44003ACDD2D, 933, 300 },
17566 { 0x8E679C2F5E44FF8F, 960, 308 },
17567 { 0xD433179D9C8CB841, 986, 316 },
17568 { 0x9E19DB92B4E31BA9, 1013, 324 },
17578 const int f = kAlpha - e - 1;
17579 const int k = ((
f * 78913) / (1 << 18)) +
static_cast<int>(
f > 0);
17581 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17585 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(
index)];
17596inline int find_largest_pow10(
const std::uint32_t n, std::uint32_t& pow10)
17599 if (n >= 1000000000)
17601 pow10 = 1000000000;
17605 if (n >= 100000000)
17650inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17651 std::uint64_t rest, std::uint64_t ten_k)
17678 && delta - rest >= ten_k
17679 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17691inline void grisu2_digit_gen(
char*
buffer,
int&
length,
int& decimal_exponent,
17692 diyfp M_minus, diyfp
w, diyfp M_plus)
17694 static_assert(kAlpha >= -60,
"internal error");
17695 static_assert(kGamma <= -32,
"internal error");
17712 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17713 std::uint64_t dist = diyfp::sub(M_plus,
w ).f;
17722 const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
17724 auto p1 =
static_cast<std::uint32_t
>(M_plus.f >> -one.e);
17725 std::uint64_t p2 = M_plus.f & (one.f - 1);
17733 std::uint32_t pow10{};
17734 const int k = find_largest_pow10(p1, pow10);
17761 const std::uint32_t d = p1 / pow10;
17762 const std::uint32_t
r = p1 % pow10;
17787 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17792 decimal_exponent += n;
17803 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17804 grisu2_round(
buffer,
length, dist, delta, rest, ten_n);
17865 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17867 const std::uint64_t d = p2 >> -one.e;
17868 const std::uint64_t
r = p2 & (one.f - 1);
17900 decimal_exponent -= m;
17908 const std::uint64_t ten_m = one.f;
17932inline void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17933 diyfp m_minus, diyfp
v, diyfp m_plus)
17947 const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
17949 const diyfp c_minus_k(cached.f, cached.e);
17952 const diyfp
w = diyfp::mul(
v, c_minus_k);
17953 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17954 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17977 const diyfp M_minus(w_minus.f + 1, w_minus.e);
17978 const diyfp M_plus (w_plus.f - 1, w_plus.e );
17980 decimal_exponent = -cached.k;
17982 grisu2_digit_gen(buf, len, decimal_exponent, M_minus,
w, M_plus);
17990template<
typename FloatType>
17992void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType
value)
17994 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
17995 "internal error: not enough precision");
18017 const boundaries
w = compute_boundaries(
static_cast<double>(
value));
18019 const boundaries
w = compute_boundaries(
value);
18022 grisu2(buf, len, decimal_exponent,
w.minus,
w.w,
w.plus);
18032inline char* append_exponent(
char* buf,
int e)
18047 auto k =
static_cast<std::uint32_t
>(e);
18053 *buf++ =
static_cast<char>(
'0' + k);
18057 *buf++ =
static_cast<char>(
'0' + (k / 10));
18059 *buf++ =
static_cast<char>(
'0' + k);
18063 *buf++ =
static_cast<char>(
'0' + (k / 100));
18065 *buf++ =
static_cast<char>(
'0' + (k / 10));
18067 *buf++ =
static_cast<char>(
'0' + k);
18084inline char* format_buffer(
char* buf,
int len,
int decimal_exponent,
18085 int min_exp,
int max_exp)
18091 const int n = len + decimal_exponent;
18097 if (k <= n && n <= max_exp)
18102 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18106 return buf + (
static_cast<size_t>(n) + 2);
18109 if (0 < n && n <= max_exp)
18116 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18118 return buf + (
static_cast<size_t>(k) + 1U);
18121 if (min_exp < n && n <= 0)
18126 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18129 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18130 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18145 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18147 buf += 1 +
static_cast<size_t>(k);
18151 return append_exponent(buf, n - 1);
18166template<
typename FloatType>
18169char* to_chars(
char*
first, const
char* last, FloatType
value)
18171 static_cast<void>(last);
18175 if (std::signbit(
value))
18182#pragma GCC diagnostic push
18183#pragma GCC diagnostic ignored "-Wfloat-equal"
18194#pragma GCC diagnostic pop
18197 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10);
18204 int decimal_exponent = 0;
18205 dtoa_impl::grisu2(
first, len, decimal_exponent,
value);
18207 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18210 constexpr int kMinExp = -4;
18212 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18215 JSON_ASSERT(last -
first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18216 JSON_ASSERT(last -
first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18218 return dtoa_impl::format_buffer(
first, len, decimal_exponent, kMinExp, kMaxExp);
18255template<
typename BasicJsonType>
18258 using string_t =
typename BasicJsonType::string_t;
18259 using number_float_t =
typename BasicJsonType::number_float_t;
18260 using number_integer_t =
typename BasicJsonType::number_integer_t;
18261 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18262 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18263 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18264 static constexpr std::uint8_t UTF8_REJECT = 1;
18275 ,
loc(
std::localeconv())
18313 const bool pretty_print,
18315 const unsigned int indent_step,
18316 const unsigned int current_indent = 0)
18318 switch (val.m_data.m_type)
18322 if (val.m_data.m_value.object->empty())
18324 o->write_characters(
"{}", 2);
18330 o->write_characters(
"{\n", 2);
18333 const auto new_indent = current_indent + indent_step;
18340 auto i = val.m_data.m_value.object->cbegin();
18341 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18344 o->write_character(
'\"');
18346 o->write_characters(
"\": ", 3);
18348 o->write_characters(
",\n", 2);
18352 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18353 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18355 o->write_character(
'\"');
18357 o->write_characters(
"\": ", 3);
18360 o->write_character(
'\n');
18361 o->write_characters(
indent_string.c_str(), current_indent);
18362 o->write_character(
'}');
18366 o->write_character(
'{');
18369 auto i = val.m_data.m_value.object->cbegin();
18370 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18372 o->write_character(
'\"');
18374 o->write_characters(
"\":", 2);
18376 o->write_character(
',');
18380 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18381 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18382 o->write_character(
'\"');
18384 o->write_characters(
"\":", 2);
18387 o->write_character(
'}');
18395 if (val.m_data.m_value.array->empty())
18397 o->write_characters(
"[]", 2);
18403 o->write_characters(
"[\n", 2);
18406 const auto new_indent = current_indent + indent_step;
18413 for (
auto i = val.m_data.m_value.array->cbegin();
18414 i != val.m_data.m_value.array->cend() - 1; ++i)
18418 o->write_characters(
",\n", 2);
18424 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18426 o->write_character(
'\n');
18427 o->write_characters(
indent_string.c_str(), current_indent);
18428 o->write_character(
']');
18432 o->write_character(
'[');
18435 for (
auto i = val.m_data.m_value.array->cbegin();
18436 i != val.m_data.m_value.array->cend() - 1; ++i)
18439 o->write_character(
',');
18444 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
18446 o->write_character(
']');
18454 o->write_character(
'\"');
18455 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
18456 o->write_character(
'\"');
18464 o->write_characters(
"{\n", 2);
18467 const auto new_indent = current_indent + indent_step;
18475 o->write_characters(
"\"bytes\": [", 10);
18477 if (!val.m_data.m_value.binary->empty())
18479 for (
auto i = val.m_data.m_value.binary->cbegin();
18480 i != val.m_data.m_value.binary->cend() - 1; ++i)
18483 o->write_characters(
", ", 2);
18485 dump_integer(val.m_data.m_value.binary->back());
18488 o->write_characters(
"],\n", 3);
18491 o->write_characters(
"\"subtype\": ", 11);
18492 if (val.m_data.m_value.binary->has_subtype())
18494 dump_integer(val.m_data.m_value.binary->subtype());
18498 o->write_characters(
"null", 4);
18500 o->write_character(
'\n');
18501 o->write_characters(
indent_string.c_str(), current_indent);
18502 o->write_character(
'}');
18506 o->write_characters(
"{\"bytes\":[", 10);
18508 if (!val.m_data.m_value.binary->empty())
18510 for (
auto i = val.m_data.m_value.binary->cbegin();
18511 i != val.m_data.m_value.binary->cend() - 1; ++i)
18514 o->write_character(
',');
18516 dump_integer(val.m_data.m_value.binary->back());
18519 o->write_characters(
"],\"subtype\":", 12);
18520 if (val.m_data.m_value.binary->has_subtype())
18522 dump_integer(val.m_data.m_value.binary->subtype());
18523 o->write_character(
'}');
18527 o->write_characters(
"null}", 5);
18535 if (val.m_data.m_value.boolean)
18537 o->write_characters(
"true", 4);
18541 o->write_characters(
"false", 5);
18548 dump_integer(val.m_data.m_value.number_integer);
18554 dump_integer(val.m_data.m_value.number_unsigned);
18560 dump_float(val.m_data.m_value.number_float);
18566 o->write_characters(
"<discarded>", 11);
18572 o->write_characters(
"null", 4);
18598 std::uint32_t codepoint{};
18606 for (std::size_t i = 0; i < s.size(); ++i)
18608 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18610 switch (decode(
state, codepoint,
byte))
18669 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
18671 if (codepoint <= 0xFFFF)
18675 static_cast<std::uint16_t
>(codepoint)));
18681 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
18682 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18683 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18751 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xEF');
18752 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBF');
18753 string_buffer[
bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type(
'\xBD');
18771 state = UTF8_ACCEPT;
18827 o->write_characters(
"\\ufffd", 6);
18831 o->write_characters(
"\xEF\xBF\xBD", 3);
18851 unsigned int count_digits(number_unsigned_t
x)
noexcept
18853 unsigned int n_digits = 1;
18862 return n_digits + 1;
18866 return n_digits + 2;
18870 return n_digits + 3;
18882 static std::string hex_bytes(std::uint8_t
byte)
18884 std::string result =
"FF";
18885 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18886 result[0] = nibble_to_hex[
byte / 16];
18887 result[1] = nibble_to_hex[
byte % 16];
18892 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18893 bool is_negative_number(NumberType
x)
18898 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18899 bool is_negative_number(NumberType )
18914 std::is_integral<NumberType>::value ||
18915 std::is_same<NumberType, number_unsigned_t>::value ||
18916 std::is_same<NumberType, number_integer_t>::value ||
18917 std::is_same<NumberType, binary_char_t>::value,
18919 void dump_integer(NumberType
x)
18921 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18924 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18925 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18926 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18927 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18928 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18929 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18930 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18931 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18932 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18933 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18940 o->write_character(
'0');
18947 number_unsigned_t abs_value;
18949 unsigned int n_chars{};
18951 if (is_negative_number(
x))
18954 abs_value = remove_sign(
static_cast<number_integer_t
>(
x));
18957 n_chars = 1 + count_digits(abs_value);
18961 abs_value =
static_cast<number_unsigned_t
>(
x);
18962 n_chars = count_digits(abs_value);
18970 buffer_ptr += n_chars;
18974 while (abs_value >= 100)
18976 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18978 *(--buffer_ptr) = digits_to_99[digits_index][1];
18979 *(--buffer_ptr) = digits_to_99[digits_index][0];
18982 if (abs_value >= 10)
18984 const auto digits_index =
static_cast<unsigned>(abs_value);
18985 *(--buffer_ptr) = digits_to_99[digits_index][1];
18986 *(--buffer_ptr) = digits_to_99[digits_index][0];
18990 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19004 void dump_float(number_float_t
x)
19007 if (!std::isfinite(
x))
19009 o->write_characters(
"null", 4);
19018 static constexpr bool is_ieee_single_or_double
19019 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
19020 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
19022 dump_float(
x, std::integral_constant<bool, is_ieee_single_or_double>());
19025 void dump_float(number_float_t
x, std::true_type )
19028 auto*
end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(),
x);
19030 o->write_characters(begin,
static_cast<size_t>(
end - begin));
19033 void dump_float(number_float_t
x, std::false_type )
19036 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19068 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
19071 const bool value_is_int_like =
19075 return c ==
'.' || c ==
'e';
19078 if (value_is_int_like)
19080 o->write_characters(
".0", 2);
19105 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19107 static const std::array<std::uint8_t, 400> utf8d =
19110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19114 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
19115 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19116 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19117 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19118 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19119 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19120 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
19121 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
19122 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
19123 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
19128 const std::uint8_t
type = utf8d[
byte];
19130 codep = (
state != UTF8_ACCEPT)
19131 ? (
byte & 0x3fu) | (codep << 6u)
19134 const std::size_t
index = 256u + (
static_cast<size_t>(
state) * 16u) +
static_cast<size_t>(
type);
19145 number_unsigned_t remove_sign(number_unsigned_t
x)
19160 number_unsigned_t remove_sign(number_integer_t
x)
noexcept
19162 JSON_ASSERT(
x < 0 &&
x < (std::numeric_limits<number_integer_t>::max)());
19163 return static_cast<number_unsigned_t
>(-(
x + 1)) + 1;
19168 output_adapter_t<char> o =
nullptr;
19210#include <functional>
19211#include <initializer_list>
19214#include <stdexcept>
19215#include <type_traits>
19228template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19229 class Allocator = std::allocator<std::pair<const Key, T>>>
19234 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19239#ifdef JSON_HAS_CPP_14
19249 template <
class It>
19252 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19257 for (
auto it = this->begin(); it != this->
end(); ++it)
19259 if (m_compare(it->first, key))
19261 return {it,
false};
19264 Container::emplace_back(key, std::forward<T>(t));
19265 return {std::prev(this->
end()),
true};
19270 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19272 for (
auto it = this->begin(); it != this->
end(); ++it)
19274 if (m_compare(it->first, key))
19276 return {it,
false};
19279 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19280 return {std::prev(this->
end()),
true};
19292 return emplace(std::forward<KeyType>(key), T{}).
first->second;
19304 return at(std::forward<KeyType>(key));
19309 for (
auto it = this->begin(); it != this->
end(); ++it)
19311 if (m_compare(it->first, key))
19317 JSON_THROW(std::out_of_range(
"key not found"));
19324 for (
auto it = this->begin(); it != this->
end(); ++it)
19326 if (m_compare(it->first, key))
19332 JSON_THROW(std::out_of_range(
"key not found"));
19337 for (
auto it = this->begin(); it != this->
end(); ++it)
19339 if (m_compare(it->first, key))
19345 JSON_THROW(std::out_of_range(
"key not found"));
19350 const T &
at(KeyType && key)
const
19352 for (
auto it = this->begin(); it != this->
end(); ++it)
19354 if (m_compare(it->first, key))
19360 JSON_THROW(std::out_of_range(
"key not found"));
19365 for (
auto it = this->begin(); it != this->
end(); ++it)
19367 if (m_compare(it->first, key))
19370 for (
auto next = it; ++next != this->
end(); ++it)
19375 Container::pop_back();
19386 for (
auto it = this->begin(); it != this->
end(); ++it)
19388 if (m_compare(it->first, key))
19391 for (
auto next = it; ++next != this->
end(); ++it)
19396 Container::pop_back();
19405 return erase(pos, std::next(pos));
19415 const auto elements_affected = std::distance(
first, last);
19416 const auto offset = std::distance(Container::begin(),
first);
19438 for (
auto it =
first; std::next(it, elements_affected) != Container::end(); ++it)
19441 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19449 Container::resize(this->
size() -
static_cast<size_type>(elements_affected));
19458 return Container::begin() +
offset;
19463 for (
auto it = this->begin(); it != this->
end(); ++it)
19465 if (m_compare(it->first, key))
19477 for (
auto it = this->begin(); it != this->
end(); ++it)
19479 if (m_compare(it->first, key))
19489 for (
auto it = this->begin(); it != this->
end(); ++it)
19491 if (m_compare(it->first, key))
19496 return Container::end();
19503 for (
auto it = this->begin(); it != this->
end(); ++it)
19505 if (m_compare(it->first, key))
19510 return Container::end();
19515 for (
auto it = this->begin(); it != this->
end(); ++it)
19517 if (m_compare(it->first, key))
19522 return Container::end();
19532 for (
auto it = this->begin(); it != this->
end(); ++it)
19534 if (m_compare(it->first,
value.first))
19536 return {it,
false};
19539 Container::push_back(
value);
19540 return {--this->
end(),
true};
19543 template<
typename InputIt>
19544 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19547 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19550 for (
auto it =
first; it != last; ++it)
19563#if defined(JSON_HAS_CPP_17)
19564 #if JSON_HAS_STATIC_RTTI
19567 #include <string_view>
19597 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
19603 friend class ::nlohmann::json_pointer;
19607 template<
typename BasicJsonType,
typename InputType>
19608 friend class ::nlohmann::detail::parser;
19609 friend ::nlohmann::detail::serializer<basic_json>;
19610 template<
typename BasicJsonType>
19611 friend class ::nlohmann::detail::iter_impl;
19612 template<
typename BasicJsonType,
typename CharType>
19613 friend class ::nlohmann::detail::binary_writer;
19614 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19615 friend class ::nlohmann::detail::binary_reader;
19616 template<
typename BasicJsonType>
19617 friend class ::nlohmann::detail::json_sax_dom_parser;
19618 template<
typename BasicJsonType>
19619 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19620 friend class ::nlohmann::detail::exception;
19624 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
19628 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19630 template<
typename InputAdapterType>
19631 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19632 InputAdapterType adapter,
19633 detail::parser_callback_t<basic_json>cb =
nullptr,
19634 const bool allow_exceptions =
true,
19635 const bool ignore_comments =
false
19638 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19639 std::move(cb), allow_exceptions, ignore_comments);
19643 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
19644 template<
typename BasicJsonType>
19645 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
19646 template<
typename BasicJsonType>
19647 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
19648 template<
typename Iterator>
19649 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
19650 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
19652 template<
typename CharType>
19653 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
19655 template<
typename InputType>
19656 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
19657 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19660 using serializer = ::nlohmann::detail::serializer<basic_json>;
19666 template<
typename T,
typename SFINAE>
19675 using input_format_t = detail::input_format_t;
19722 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19724 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19751 result[
"copyright"] =
"(C) 2013-2023 Niels Lohmann";
19752 result[
"name"] =
"JSON for Modern C++";
19753 result[
"url"] =
"https://github.com/nlohmann/json";
19754 result[
"version"][
"string"] =
19763 result[
"platform"] =
"win32";
19764#elif defined __linux__
19765 result[
"platform"] =
"linux";
19766#elif defined __APPLE__
19767 result[
"platform"] =
"apple";
19768#elif defined __unix__
19769 result[
"platform"] =
"unix";
19771 result[
"platform"] =
"unknown";
19774#if defined(__ICC) || defined(__INTEL_COMPILER)
19775 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19776#elif defined(__clang__)
19777 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19778#elif defined(__GNUC__) || defined(__GNUG__)
19779 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19780 std::to_string(__GNUC__),
'.',
19781 std::to_string(__GNUC_MINOR__),
'.',
19782 std::to_string(__GNUC_PATCHLEVEL__))
19785#elif defined(__HP_cc) || defined(__HP_aCC)
19786 result[
"compiler"] =
"hp"
19787#elif defined(__IBMCPP__)
19788 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19789#elif defined(_MSC_VER)
19790 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19791#elif defined(__PGI)
19792 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19793#elif defined(__SUNPRO_CC)
19794 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19796 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19799#if defined(_MSVC_LANG)
19800 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
19801#elif defined(__cplusplus)
19802 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
19804 result[
"compiler"][
"c++"] =
"unknown";
19822#if defined(JSON_HAS_CPP_14)
19835 AllocatorType<std::pair<
const StringType,
19840 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19864 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19875 template<
typename T,
typename... Args>
19877 static T* create(Args&& ... args)
19879 AllocatorType<T> alloc;
19880 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19882 auto deleter = [&](T * obj)
19884 AllocatorTraits::deallocate(alloc, obj, 1);
19886 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19887 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19889 return obj.release();
19942 json_value() =
default;
19956 case value_t::object:
19958 object = create<object_t>();
19962 case value_t::array:
19964 array = create<array_t>();
19968 case value_t::string:
19970 string = create<string_t>(
"");
19974 case value_t::binary:
19976 binary = create<binary_t>();
19980 case value_t::boolean:
19982 boolean =
static_cast<boolean_t>(
false);
19986 case value_t::number_integer:
19992 case value_t::number_unsigned:
19998 case value_t::number_float:
20004 case value_t::null:
20010 case value_t::discarded:
20056 (t == value_t::object &&
object ==
nullptr) ||
20057 (t == value_t::array && array ==
nullptr) ||
20058 (t == value_t::string &&
string ==
nullptr) ||
20059 (t == value_t::binary && binary ==
nullptr)
20065 if (t == value_t::array || t == value_t::object)
20068 std::vector<basic_json> stack;
20071 if (t == value_t::array)
20073 stack.reserve(
array->size());
20074 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
20079 for (
auto&& it : *
object)
20081 stack.push_back(std::move(it.second));
20085 while (!stack.empty())
20088 basic_json current_item(std::move(stack.back()));
20093 if (current_item.is_array())
20095 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
20097 current_item.m_data.m_value.array->clear();
20099 else if (current_item.is_object())
20103 stack.push_back(std::move(it.second));
20106 current_item.m_data.m_value.object->clear();
20116 case value_t::object:
20118 AllocatorType<object_t> alloc;
20119 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20120 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20124 case value_t::array:
20126 AllocatorType<array_t> alloc;
20127 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20128 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20132 case value_t::string:
20134 AllocatorType<string_t> alloc;
20135 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20136 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20140 case value_t::binary:
20142 AllocatorType<binary_t> alloc;
20143 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20144 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20148 case value_t::null:
20149 case value_t::boolean:
20150 case value_t::number_integer:
20151 case value_t::number_unsigned:
20152 case value_t::number_float:
20153 case value_t::discarded:
20181 void assert_invariant(
bool check_parents =
true) const noexcept
20188#if JSON_DIAGNOSTICS
20194 return j.m_parent ==
this;
20199 static_cast<void>(check_parents);
20204#if JSON_DIAGNOSTICS
20207 case value_t::array:
20211 element.m_parent =
this;
20216 case value_t::object:
20220 element.second.m_parent =
this;
20225 case value_t::null:
20226 case value_t::string:
20227 case value_t::boolean:
20228 case value_t::number_integer:
20229 case value_t::number_unsigned:
20230 case value_t::number_float:
20231 case value_t::binary:
20232 case value_t::discarded:
20239 iterator set_parents(
iterator it,
typename iterator::difference_type count_set_parents)
20241#if JSON_DIAGNOSTICS
20242 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20244 (it + i)->m_parent =
this;
20247 static_cast<void>(count_set_parents);
20252 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
20254#if JSON_DIAGNOSTICS
20255 if (old_capacity !=
static_cast<std::size_t
>(-1))
20269#ifdef JSON_HEDLEY_MSVC_VERSION
20270#pragma warning(push )
20271#pragma warning(disable : 4127)
20278#ifdef JSON_HEDLEY_MSVC_VERSION
20279#pragma warning( pop )
20284 static_cast<void>(j);
20285 static_cast<void>(old_capacity);
20297 using parse_event_t = detail::parse_event_t;
20317 assert_invariant();
20325 assert_invariant();
20330 template <
typename CompatibleType,
20335 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20336 std::forward<CompatibleType>(val))))
20338 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20340 assert_invariant();
20345 template <
typename BasicJsonType,
20350 using other_boolean_t =
typename BasicJsonType::boolean_t;
20351 using other_number_float_t =
typename BasicJsonType::number_float_t;
20352 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20353 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20354 using other_string_t =
typename BasicJsonType::string_t;
20355 using other_object_t =
typename BasicJsonType::object_t;
20356 using other_array_t =
typename BasicJsonType::array_t;
20357 using other_binary_t =
typename BasicJsonType::binary_t;
20359 switch (val.type())
20361 case value_t::boolean:
20362 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20364 case value_t::number_float:
20365 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20367 case value_t::number_integer:
20368 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20370 case value_t::number_unsigned:
20371 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20373 case value_t::string:
20374 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20376 case value_t::object:
20377 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20379 case value_t::array:
20380 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20382 case value_t::binary:
20383 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20385 case value_t::null:
20388 case value_t::discarded:
20389 m_data.m_type = value_t::discarded;
20396 assert_invariant();
20402 bool type_deduction =
true,
20403 value_t manual_type = value_t::array)
20407 bool is_an_object = std::all_of(init.begin(), init.end(),
20413 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
20417 if (!type_deduction)
20420 if (manual_type == value_t::array)
20422 is_an_object =
false;
20435 m_data.m_type = value_t::object;
20436 m_data.m_value = value_t::object;
20438 for (
auto& element_ref : init)
20442 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20443 std::move((*element.m_data.m_value.array)[1]));
20449 m_data.m_type = value_t::array;
20450 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20454 assert_invariant();
20463 res.m_data.m_type = value_t::binary;
20464 res.m_data.m_value = init;
20471 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20474 res.m_data.m_type = value_t::binary;
20475 res.m_data.m_value =
binary_t(init, subtype);
20485 res.m_data.m_type = value_t::binary;
20486 res.m_data.m_value = std::move(init);
20493 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20496 res.m_data.m_type = value_t::binary;
20497 res.m_data.m_value =
binary_t(std::move(init), subtype);
20506 return basic_json(init,
false, value_t::array);
20514 return basic_json(init,
false, value_t::object);
20523 assert_invariant();
20528 template <
class InputIT,
typename std::enable_if <
20529 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20530 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
20548 case value_t::boolean:
20549 case value_t::number_float:
20550 case value_t::number_integer:
20551 case value_t::number_unsigned:
20552 case value_t::string:
20555 || !last.m_it.primitive_iterator.is_end()))
20562 case value_t::null:
20563 case value_t::object:
20564 case value_t::array:
20565 case value_t::binary:
20566 case value_t::discarded:
20573 case value_t::number_integer:
20575 m_data.m_value.number_integer =
first.m_object->m_data.m_value.number_integer;
20579 case value_t::number_unsigned:
20581 m_data.m_value.number_unsigned =
first.m_object->m_data.m_value.number_unsigned;
20585 case value_t::number_float:
20587 m_data.m_value.number_float =
first.m_object->m_data.m_value.number_float;
20591 case value_t::boolean:
20593 m_data.m_value.boolean =
first.m_object->m_data.m_value.boolean;
20597 case value_t::string:
20599 m_data.m_value = *
first.m_object->m_data.m_value.string;
20603 case value_t::object:
20605 m_data.m_value.object = create<object_t>(
first.m_it.object_iterator,
20606 last.m_it.object_iterator);
20610 case value_t::array:
20612 m_data.m_value.array = create<array_t>(
first.m_it.array_iterator,
20613 last.m_it.array_iterator);
20617 case value_t::binary:
20619 m_data.m_value = *
first.m_object->m_data.m_value.binary;
20623 case value_t::null:
20624 case value_t::discarded:
20630 assert_invariant();
20637 template<
typename JsonRef,
20639 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20645 : json_base_class_t(other)
20649 other.assert_invariant();
20653 case value_t::object:
20659 case value_t::array:
20665 case value_t::string:
20671 case value_t::boolean:
20677 case value_t::number_integer:
20683 case value_t::number_unsigned:
20685 m_data.m_value = other.
m_data.m_value.number_unsigned;
20689 case value_t::number_float:
20695 case value_t::binary:
20701 case value_t::null:
20702 case value_t::discarded:
20708 assert_invariant();
20714 : json_base_class_t(std::forward<json_base_class_t>(other)),
20715 m_data(std::move(other.m_data))
20718 other.assert_invariant(
false);
20721 other.m_data.m_type = value_t::null;
20722 other.m_data.m_value = {};
20725 assert_invariant();
20731 std::is_nothrow_move_constructible<value_t>::value&&
20732 std::is_nothrow_move_assignable<value_t>::value&&
20733 std::is_nothrow_move_constructible<json_value>::value&&
20734 std::is_nothrow_move_assignable<json_value>::value&&
20735 std::is_nothrow_move_assignable<json_base_class_t>::value
20739 other.assert_invariant();
20744 json_base_class_t::operator=(std::move(other));
20747 assert_invariant();
20755 assert_invariant(
false);
20772 const char indent_char =
' ',
20773 const bool ensure_ascii =
false,
20777 serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
20781 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20785 s.dump(*
this,
false, ensure_ascii, 0);
20816 return m_data.m_type == value_t::null;
20823 return m_data.m_type == value_t::boolean;
20837 return m_data.m_type == value_t::number_integer ||
m_data.m_type == value_t::number_unsigned;
20844 return m_data.m_type == value_t::number_unsigned;
20851 return m_data.m_type == value_t::number_float;
20858 return m_data.m_type == value_t::object;
20865 return m_data.m_type == value_t::array;
20872 return m_data.m_type == value_t::string;
20879 return m_data.m_type == value_t::binary;
20886 return m_data.m_type == value_t::discarded;
20908 return m_data.m_value.boolean;
20933 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
21021 template<
typename ReferenceType,
typename ThisType>
21022 static ReferenceType get_ref_impl(ThisType& obj)
21025 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21042 template<
typename PointerType,
typename std::enable_if<
21043 std::is_pointer<PointerType>::value,
int>
::type = 0>
21044 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21047 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21052 template <
typename PointerType,
typename std::enable_if <
21053 std::is_pointer<PointerType>::value&&
21054 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
21055 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21058 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21100 template <
typename ValueType,
21106 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21108 auto ret = ValueType();
21109 JSONSerializer<ValueType>::from_json(*
this, ret);
21143 template <
typename ValueType,
21148 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21150 return JSONSerializer<ValueType>::from_json(*
this);
21168 template <
typename BasicJsonType,
21191 template<
typename BasicJsonType,
21193 std::is_same<BasicJsonType, basic_json_t>::value,
21204 template<
typename PointerType,
21206 std::is_pointer<PointerType>::value,
21209 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21212 return get_ptr<PointerType>();
21239 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21240#if defined(JSON_HAS_CPP_14)
21244 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21250 static_assert(!std::is_reference<ValueTypeCV>::value,
21251 "get() cannot be used with reference types, you might want to use get_ref()");
21282 template<
typename PointerType,
typename std::enable_if<
21283 std::is_pointer<PointerType>::value,
int>
::type = 0>
21284 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
21287 return get_ptr<PointerType>();
21292 template <
typename ValueType,
21297 ValueType &
get_to(ValueType&
v)
const noexcept(
noexcept(
21298 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(),
v)))
21300 JSONSerializer<ValueType>::from_json(*
this,
v);
21306 template<
typename ValueType,
21317 typename T, std::size_t N,
21318 typename Array = T (&)[N],
21322 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21323 std::declval<const basic_json_t&>(),
v)))
21325 JSONSerializer<Array>::from_json(*
this,
v);
21331 template<
typename ReferenceType,
typename std::enable_if<
21332 std::is_reference<ReferenceType>::value,
int>
::type = 0>
21336 return get_ref_impl<ReferenceType>(*
this);
21341 template <
typename ReferenceType,
typename std::enable_if <
21342 std::is_reference<ReferenceType>::value&&
21343 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
21347 return get_ref_impl<ReferenceType>(*
this);
21379 template <
typename ValueType,
typename std::enable_if <
21387#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21390#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
21398 return get<ValueType>();
21410 return *get_ptr<binary_t*>();
21422 return *get_ptr<const binary_t*>();
21444 return set_parent(
m_data.m_value.array->at(idx));
21491 auto it =
m_data.m_value.object->find(key);
21492 if (it ==
m_data.m_value.object->end())
21496 return set_parent(it->second);
21511 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21512 if (it ==
m_data.m_value.object->end())
21516 return set_parent(it->second);
21529 auto it =
m_data.m_value.object->find(key);
21530 if (it ==
m_data.m_value.object->end())
21549 auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
21550 if (it ==
m_data.m_value.object->end())
21564 m_data.m_type = value_t::array;
21566 assert_invariant();
21573 if (idx >=
m_data.m_value.array->size())
21575#if JSON_DIAGNOSTICS
21577 const auto old_size =
m_data.m_value.array->size();
21578 const auto old_capacity =
m_data.m_value.array->capacity();
21580 m_data.m_value.array->resize(idx + 1);
21582#if JSON_DIAGNOSTICS
21591 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21594 assert_invariant();
21597 return m_data.m_value.array->operator[](idx);
21623 m_data.m_type = value_t::object;
21625 assert_invariant();
21631 auto result =
m_data.m_value.object->emplace(std::move(key),
nullptr);
21632 return set_parent(result.first->second);
21655 template<
typename T>
21658 return operator[](
typename object_t::key_type(key));
21661 template<
typename T>
21664 return operator[](
typename object_t::key_type(key));
21676 m_data.m_type = value_t::object;
21678 assert_invariant();
21684 auto result =
m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21685 return set_parent(result.first->second);
21700 auto it =
m_data.
m_value.object->find(std::forward<KeyType>(key));
21709 template<
typename KeyType>
21713 template<
typename ValueType>
21714 using value_return_type = std::conditional <
21716 string_t,
typename std::decay<ValueType>::type >;
21724 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21725 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21731 const auto it =
find(key);
21734 return it->template get<ValueType>();
21737 return default_value;
21745 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21749 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21750 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
21756 const auto it =
find(key);
21759 return it->template get<ReturnType>();
21762 return std::forward<ValueType>(default_value);
21773 && is_comparable_with_object_key<KeyType>::value
21775 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21776 ValueType
value(KeyType && key,
const ValueType& default_value)
const
21782 const auto it =
find(std::forward<KeyType>(key));
21785 return it->template get<ValueType>();
21788 return default_value;
21796 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21800 && is_comparable_with_object_key<KeyType>::value
21802 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21803 ReturnType
value(KeyType && key, ValueType && default_value)
const
21809 const auto it =
find(std::forward<KeyType>(key));
21812 return it->template get<ReturnType>();
21815 return std::forward<ValueType>(default_value);
21825 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21834 return ptr.get_checked(
this).template get<ValueType>();
21838 return default_value;
21847 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21850 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21859 return ptr.get_checked(
this).template get<ReturnType>();
21863 return std::forward<ValueType>(default_value);
21873 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21875 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
21877 return value(ptr.convert(), default_value);
21880 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21884 && !std::is_same<value_t, detail::uncvref_t<ValueType>>
::value,
int > = 0 >
21888 return value(ptr.convert(), std::forward<ValueType>(default_value));
21926 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21927 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21936 IteratorType result =
end();
21940 case value_t::boolean:
21941 case value_t::number_float:
21942 case value_t::number_integer:
21943 case value_t::number_unsigned:
21944 case value_t::string:
21945 case value_t::binary:
21954 AllocatorType<string_t> alloc;
21955 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
21956 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
21957 m_data.m_value.string =
nullptr;
21961 AllocatorType<binary_t> alloc;
21962 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
21963 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
21964 m_data.m_value.binary =
nullptr;
21967 m_data.m_type = value_t::null;
21968 assert_invariant();
21972 case value_t::object:
21974 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
21978 case value_t::array:
21980 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
21984 case value_t::null:
21985 case value_t::discarded:
21996 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21997 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22006 IteratorType result =
end();
22010 case value_t::boolean:
22011 case value_t::number_float:
22012 case value_t::number_integer:
22013 case value_t::number_unsigned:
22014 case value_t::string:
22015 case value_t::binary:
22018 || !last.m_it.primitive_iterator.is_end()))
22025 AllocatorType<string_t> alloc;
22026 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22027 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22028 m_data.m_value.string =
nullptr;
22032 AllocatorType<binary_t> alloc;
22033 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22034 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22035 m_data.m_value.binary =
nullptr;
22038 m_data.m_type = value_t::null;
22039 assert_invariant();
22043 case value_t::object:
22045 result.m_it.object_iterator =
m_data.m_value.object->erase(
first.m_it.object_iterator,
22046 last.m_it.object_iterator);
22050 case value_t::array:
22052 result.m_it.array_iterator =
m_data.m_value.array->erase(
first.m_it.array_iterator,
22053 last.m_it.array_iterator);
22057 case value_t::null:
22058 case value_t::discarded:
22069 size_type erase_internal(KeyType && key)
22077 return m_data.m_value.object->erase(std::forward<KeyType>(key));
22082 size_type erase_internal(KeyType && key)
22090 const auto it =
m_data.m_value.object->find(std::forward<KeyType>(key));
22091 if (it !=
m_data.m_value.object->end())
22093 m_data.m_value.object->erase(it);
22107 return erase_internal(key);
22116 return erase_internal(std::forward<KeyType>(key));
22152 auto result =
end();
22156 result.m_it.object_iterator =
m_data.m_value.object->find(key);
22166 auto result =
cend();
22170 result.m_it.object_iterator =
m_data.m_value.object->find(key);
22182 auto result =
end();
22186 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(key));
22198 auto result =
cend();
22202 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(key));
22223 return is_object() ?
m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
22228 bool contains(
const typename object_t::key_type& key)
const
22239 return is_object() &&
m_data.m_value.object->find(std::forward<KeyType>(key)) !=
m_data.m_value.object->end();
22246 return ptr.contains(
this);
22249 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22253 return ptr.contains(
this);
22270 result.set_begin();
22286 result.set_begin();
22366 return ref.items();
22377 return ref.items();
22384 return iteration_proxy<iterator>(*
this);
22389 iteration_proxy<const_iterator>
items() const noexcept
22391 return iteration_proxy<const_iterator>(*
this);
22409 case value_t::null:
22415 case value_t::array:
22418 return m_data.m_value.array->empty();
22421 case value_t::object:
22424 return m_data.m_value.object->empty();
22427 case value_t::string:
22428 case value_t::boolean:
22429 case value_t::number_integer:
22430 case value_t::number_unsigned:
22431 case value_t::number_float:
22432 case value_t::binary:
22433 case value_t::discarded:
22448 case value_t::null:
22454 case value_t::array:
22457 return m_data.m_value.array->size();
22460 case value_t::object:
22463 return m_data.m_value.object->size();
22466 case value_t::string:
22467 case value_t::boolean:
22468 case value_t::number_integer:
22469 case value_t::number_unsigned:
22470 case value_t::number_float:
22471 case value_t::binary:
22472 case value_t::discarded:
22487 case value_t::array:
22490 return m_data.m_value.array->max_size();
22493 case value_t::object:
22496 return m_data.m_value.object->max_size();
22499 case value_t::null:
22500 case value_t::string:
22501 case value_t::boolean:
22502 case value_t::number_integer:
22503 case value_t::number_unsigned:
22504 case value_t::number_float:
22505 case value_t::binary:
22506 case value_t::discarded:
22530 case value_t::number_integer:
22532 m_data.m_value.number_integer = 0;
22536 case value_t::number_unsigned:
22538 m_data.m_value.number_unsigned = 0;
22542 case value_t::number_float:
22544 m_data.m_value.number_float = 0.0;
22548 case value_t::boolean:
22550 m_data.m_value.boolean =
false;
22554 case value_t::string:
22556 m_data.m_value.string->clear();
22560 case value_t::binary:
22562 m_data.m_value.binary->clear();
22566 case value_t::array:
22568 m_data.m_value.array->clear();
22572 case value_t::object:
22574 m_data.m_value.object->clear();
22578 case value_t::null:
22579 case value_t::discarded:
22598 m_data.m_type = value_t::array;
22599 m_data.m_value = value_t::array;
22600 assert_invariant();
22604 const auto old_capacity =
m_data.m_value.array->capacity();
22605 m_data.m_value.array->push_back(std::move(val));
22606 set_parent(
m_data.m_value.array->back(), old_capacity);
22631 m_data.m_type = value_t::array;
22632 m_data.m_value = value_t::array;
22633 assert_invariant();
22637 const auto old_capacity =
m_data.m_value.array->capacity();
22638 m_data.m_value.array->push_back(val);
22639 set_parent(
m_data.m_value.array->back(), old_capacity);
22663 m_data.m_type = value_t::object;
22664 m_data.m_value = value_t::object;
22665 assert_invariant();
22669 auto res =
m_data.m_value.object->insert(val);
22670 set_parent(res.first->second);
22685 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
22687 basic_json&& key = init.begin()->moved_or_copied();
22688 push_back(
typename object_t::value_type(
22689 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22707 template<
class... Args>
22719 m_data.m_type = value_t::array;
22720 m_data.m_value = value_t::array;
22721 assert_invariant();
22725 const auto old_capacity =
m_data.m_value.array->capacity();
22726 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
22727 return set_parent(
m_data.m_value.array->back(), old_capacity);
22732 template<
class... Args>
22744 m_data.m_type = value_t::object;
22745 m_data.m_value = value_t::object;
22746 assert_invariant();
22750 auto res =
m_data.m_value.object->emplace(std::forward<Args>(args)...);
22751 set_parent(res.first->second);
22755 it.m_it.object_iterator = res.first;
22758 return {it, res.second};
22764 template<
typename... Args>
22770 auto insert_pos = std::distance(
m_data.m_value.array->begin(), pos.m_it.array_iterator);
22771 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22772 result.m_it.array_iterator =
m_data.m_value.array->begin() + insert_pos;
22806 return insert(pos, val);
22902 m_data.m_value.object->insert(
first.m_it.object_iterator, last.m_it.object_iterator);
22919 m_data.m_type = value_t::object;
22920 m_data.m_value.object = create<object_t>();
22921 assert_invariant();
22941 for (
auto it =
first; it != last; ++it)
22943 if (merge_objects && it.value().is_object())
22945 auto it2 =
m_data.m_value.object->find(it.key());
22946 if (it2 !=
m_data.m_value.object->end())
22948 it2->second.update(it.value(),
true);
22952 m_data.m_value.object->operator[](it.key()) = it.value();
22953#if JSON_DIAGNOSTICS
22954 m_data.m_value.object->operator[](it.key()).m_parent =
this;
22962 std::is_nothrow_move_constructible<value_t>::value&&
22963 std::is_nothrow_move_assignable<value_t>::value&&
22964 std::is_nothrow_move_constructible<json_value>::value&&
22965 std::is_nothrow_move_assignable<json_value>::value
22972 other.set_parents();
22973 assert_invariant();
22979 std::is_nothrow_move_constructible<value_t>::value&&
22980 std::is_nothrow_move_assignable<value_t>::value&&
22981 std::is_nothrow_move_constructible<json_value>::value&&
22982 std::is_nothrow_move_assignable<json_value>::value
23054 void swap(
typename binary_t::container_type& other)
23079#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23080 const auto lhs_type = lhs.type(); \
23081 const auto rhs_type = rhs.type(); \
23083 if (lhs_type == rhs_type) \
23085 switch (lhs_type) \
23087 case value_t::array: \
23088 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23090 case value_t::object: \
23091 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23093 case value_t::null: \
23094 return (null_result); \
23096 case value_t::string: \
23097 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23099 case value_t::boolean: \
23100 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23102 case value_t::number_integer: \
23103 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23105 case value_t::number_unsigned: \
23106 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23108 case value_t::number_float: \
23109 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23111 case value_t::binary: \
23112 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23114 case value_t::discarded: \
23116 return (unordered_result); \
23119 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23121 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23123 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23125 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23127 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23129 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23131 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23133 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23135 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23137 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23139 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23141 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23143 else if(compares_unordered(lhs, rhs))\
23145 return (unordered_result);\
23148 return (default_result);
23163#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23174 return compares_unordered(*
this,
rhs,
inverse);
23178#if JSON_HAS_THREE_WAY_COMPARISON
23184#pragma GCC diagnostic push
23185#pragma GCC diagnostic ignored "-Wfloat-equal"
23190#pragma GCC diagnostic pop
23196 template<
typename ScalarType>
23197 requires std::is_scalar_v<ScalarType>
23207 if (compares_unordered(
rhs,
true))
23222 std::partial_ordering::equivalent,
23223 std::partial_ordering::unordered,
23224 lhs_type <=> rhs_type)
23229 template<
typename ScalarType>
23230 requires std::is_scalar_v<ScalarType>
23231 std::partial_ordering operator<=>(ScalarType
rhs)
const noexcept
23236#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23245 if (compares_unordered(
rhs,
true))
23249 return !(
rhs < *
this);
23254 template<
typename ScalarType>
23255 requires std::is_scalar_v<ScalarType>
23256 bool operator<=(ScalarType
rhs)
const noexcept
23266 if (compares_unordered(
rhs,
true))
23270 return !(*
this <
rhs);
23275 template<
typename ScalarType>
23276 requires std::is_scalar_v<ScalarType>
23277 bool operator>=(ScalarType
rhs)
const noexcept
23288#pragma GCC diagnostic push
23289#pragma GCC diagnostic ignored "-Wfloat-equal"
23293#pragma GCC diagnostic pop
23299 template<
typename ScalarType,
typename std::enable_if<
23300 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23308 template<
typename ScalarType,
typename std::enable_if<
23309 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23319 if (compares_unordered(lhs,
rhs,
true))
23323 return !(lhs ==
rhs);
23328 template<
typename ScalarType,
typename std::enable_if<
23329 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23337 template<
typename ScalarType,
typename std::enable_if<
23338 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23356 template<
typename ScalarType,
typename std::enable_if<
23357 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23365 template<
typename ScalarType,
typename std::enable_if<
23366 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23376 if (compares_unordered(lhs,
rhs,
true))
23380 return !(
rhs < lhs);
23385 template<
typename ScalarType,
typename std::enable_if<
23386 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23394 template<
typename ScalarType,
typename std::enable_if<
23395 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23406 if (compares_unordered(lhs,
rhs))
23410 return !(lhs <=
rhs);
23415 template<
typename ScalarType,
typename std::enable_if<
23416 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23424 template<
typename ScalarType,
typename std::enable_if<
23425 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23435 if (compares_unordered(lhs,
rhs,
true))
23439 return !(lhs <
rhs);
23444 template<
typename ScalarType,
typename std::enable_if<
23445 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23453 template<
typename ScalarType,
typename std::enable_if<
23454 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23461#undef JSON_IMPLEMENT_OPERATOR
23477 const bool pretty_print = o.width() > 0;
23478 const auto indentation = pretty_print ? o.width() : 0;
23484 serializer s(detail::output_adapter<char>(o), o.fill());
23485 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23512 template<
typename InputType>
23516 const bool allow_exceptions =
true,
23517 const bool ignore_comments =
false)
23520 parser(detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
23526 template<
typename IteratorType>
23531 const bool allow_exceptions =
true,
23532 const bool ignore_comments =
false)
23535 parser(detail::input_adapter(std::move(
first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
23541 static basic_json parse(detail::span_input_adapter&& i,
23543 const bool allow_exceptions =
true,
23544 const bool ignore_comments =
false)
23547 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
23553 template<
typename InputType>
23554 static bool accept(InputType&& i,
23555 const bool ignore_comments =
false)
23557 return parser(detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23562 template<
typename IteratorType>
23563 static bool accept(IteratorType
first, IteratorType last,
23564 const bool ignore_comments =
false)
23566 return parser(detail::input_adapter(std::move(
first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23571 static bool accept(detail::span_input_adapter&& i,
23572 const bool ignore_comments =
false)
23574 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23579 template <
typename InputType,
typename SAX>
23582 input_format_t
format = input_format_t::
json,
23583 const
bool strict = true,
23584 const
bool ignore_comments = false)
23586 auto ia = detail::input_adapter(std::forward<InputType>(i));
23587 return format == input_format_t::json
23588 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23594 template<
class IteratorType,
class SAX>
23597 input_format_t
format = input_format_t::
json,
23598 const
bool strict = true,
23599 const
bool ignore_comments = false)
23601 auto ia = detail::input_adapter(std::move(
first), std::move(last));
23602 return format == input_format_t::json
23603 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23612 template <
typename SAX>
23616 input_format_t
format = input_format_t::
json,
23617 const
bool strict = true,
23618 const
bool ignore_comments = false)
23621 return format == input_format_t::json
23623 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23644 parser(detail::input_adapter(i)).parse(
false, j);
23661 case value_t::null:
23663 case value_t::object:
23665 case value_t::array:
23667 case value_t::string:
23669 case value_t::boolean:
23671 case value_t::binary:
23673 case value_t::discarded:
23674 return "discarded";
23675 case value_t::number_integer:
23676 case value_t::number_unsigned:
23677 case value_t::number_float:
23691 value_t m_type = value_t::null;
23704 m_value.array = create<array_t>(cnt, val);
23721#if JSON_DIAGNOSTICS
23738 std::vector<std::uint8_t> result;
23747 binary_writer<std::uint8_t>(o).write_cbor(j);
23754 binary_writer<char>(o).write_cbor(j);
23761 std::vector<std::uint8_t> result;
23770 binary_writer<std::uint8_t>(o).write_msgpack(j);
23777 binary_writer<char>(o).write_msgpack(j);
23783 const bool use_size =
false,
23784 const bool use_type =
false)
23786 std::vector<std::uint8_t> result;
23787 to_ubjson(j, result, use_size, use_type);
23794 const bool use_size =
false,
const bool use_type =
false)
23796 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
23802 const bool use_size =
false,
const bool use_type =
false)
23804 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23810 const bool use_size =
false,
23811 const bool use_type =
false)
23813 std::vector<std::uint8_t> result;
23814 to_bjdata(j, result, use_size, use_type);
23821 const bool use_size =
false,
const bool use_type =
false)
23823 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
23829 const bool use_size =
false,
const bool use_type =
false)
23831 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
23838 std::vector<std::uint8_t> result;
23847 binary_writer<std::uint8_t>(o).write_bson(j);
23854 binary_writer<char>(o).write_bson(j);
23859 template<
typename InputType>
23862 const bool strict =
true,
23863 const bool allow_exceptions =
true,
23868 auto ia = detail::input_adapter(std::forward<InputType>(i));
23869 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23870 return res ? result :
basic_json(value_t::discarded);
23875 template<
typename IteratorType>
23878 const bool strict =
true,
23879 const bool allow_exceptions =
true,
23884 auto ia = detail::input_adapter(std::move(
first), std::move(last));
23885 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23886 return res ? result :
basic_json(value_t::discarded);
23889 template<
typename T>
23893 const
bool strict = true,
23894 const
bool allow_exceptions = true,
23897 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23903 const
bool strict = true,
23904 const
bool allow_exceptions = true,
23911 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23912 return res ? result :
basic_json(value_t::discarded);
23917 template<
typename InputType>
23920 const bool strict =
true,
23921 const bool allow_exceptions =
true)
23925 auto ia = detail::input_adapter(std::forward<InputType>(i));
23926 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23927 return res ? result :
basic_json(value_t::discarded);
23932 template<
typename IteratorType>
23935 const bool strict =
true,
23936 const bool allow_exceptions =
true)
23940 auto ia = detail::input_adapter(std::move(
first), std::move(last));
23941 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23942 return res ? result :
basic_json(value_t::discarded);
23945 template<
typename T>
23949 const
bool strict = true,
23950 const
bool allow_exceptions = true)
23952 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23958 const
bool strict = true,
23959 const
bool allow_exceptions = true)
23965 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23966 return res ? result :
basic_json(value_t::discarded);
23971 template<
typename InputType>
23974 const bool strict =
true,
23975 const bool allow_exceptions =
true)
23979 auto ia = detail::input_adapter(std::forward<InputType>(i));
23980 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23981 return res ? result :
basic_json(value_t::discarded);
23986 template<
typename IteratorType>
23989 const bool strict =
true,
23990 const bool allow_exceptions =
true)
23994 auto ia = detail::input_adapter(std::move(
first), std::move(last));
23995 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23996 return res ? result :
basic_json(value_t::discarded);
23999 template<
typename T>
24003 const
bool strict = true,
24004 const
bool allow_exceptions = true)
24006 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24012 const
bool strict = true,
24013 const
bool allow_exceptions = true)
24019 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24020 return res ? result :
basic_json(value_t::discarded);
24025 template<
typename InputType>
24028 const bool strict =
true,
24029 const bool allow_exceptions =
true)
24033 auto ia = detail::input_adapter(std::forward<InputType>(i));
24034 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24035 return res ? result :
basic_json(value_t::discarded);
24040 template<
typename IteratorType>
24043 const bool strict =
true,
24044 const bool allow_exceptions =
true)
24048 auto ia = detail::input_adapter(std::move(
first), std::move(last));
24049 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24050 return res ? result :
basic_json(value_t::discarded);
24055 template<
typename InputType>
24058 const bool strict =
true,
24059 const bool allow_exceptions =
true)
24063 auto ia = detail::input_adapter(std::forward<InputType>(i));
24064 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24065 return res ? result :
basic_json(value_t::discarded);
24070 template<
typename IteratorType>
24073 const bool strict =
true,
24074 const bool allow_exceptions =
true)
24078 auto ia = detail::input_adapter(std::move(
first), std::move(last));
24079 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24080 return res ? result :
basic_json(value_t::discarded);
24083 template<
typename T>
24087 const
bool strict = true,
24088 const
bool allow_exceptions = true)
24090 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24096 const
bool strict = true,
24097 const
bool allow_exceptions = true)
24103 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24104 return res ? result :
basic_json(value_t::discarded);
24119 return ptr.get_unchecked(
this);
24122 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24126 return ptr.get_unchecked(
this);
24133 return ptr.get_unchecked(
this);
24136 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24140 return ptr.get_unchecked(
this);
24147 return ptr.get_checked(
this);
24150 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24154 return ptr.get_checked(
this);
24161 return ptr.get_checked(
this);
24164 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24168 return ptr.get_checked(
this);
24176 json_pointer::flatten(
"", *
this, result);
24184 return json_pointer::unflatten(*
this);
24202 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24204 const auto get_op = [](
const std::string & op)
24208 return patch_operations::add;
24210 if (op ==
"remove")
24212 return patch_operations::remove;
24214 if (op ==
"replace")
24216 return patch_operations::replace;
24220 return patch_operations::move;
24224 return patch_operations::copy;
24228 return patch_operations::test;
24231 return patch_operations::invalid;
24246 if (top_pointer != ptr)
24248 result.
at(top_pointer);
24252 const auto last_path = ptr.
back();
24257 switch (parent.
m_data.m_type)
24259 case value_t::null:
24260 case value_t::object:
24263 parent[last_path] = val;
24267 case value_t::array:
24269 if (last_path ==
"-")
24276 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24290 case value_t::string:
24291 case value_t::boolean:
24292 case value_t::number_integer:
24293 case value_t::number_unsigned:
24294 case value_t::number_float:
24295 case value_t::binary:
24296 case value_t::discarded:
24303 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24306 const auto last_path = ptr.
back();
24314 auto it = parent.
find(last_path);
24327 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24338 for (
const auto& val : json_patch)
24341 const auto get_value = [&val](
const std::string & op,
24342 const std::string & member,
24346 auto it = val.
m_data.m_value.object->find(member);
24349 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24376 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24377 const auto path = get_value(op,
"path",
true).template get<std::string>();
24380 switch (get_op(op))
24382 case patch_operations::add:
24384 operation_add(ptr, get_value(
"add",
"value",
false));
24388 case patch_operations::remove:
24390 operation_remove(ptr);
24394 case patch_operations::replace:
24397 result.
at(ptr) = get_value(
"replace",
"value",
false);
24401 case patch_operations::move:
24403 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24413 operation_remove(from_ptr);
24414 operation_add(ptr,
v);
24418 case patch_operations::copy:
24420 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24429 operation_add(ptr,
v);
24433 case patch_operations::test:
24435 bool success =
false;
24440 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24456 case patch_operations::invalid:
24480 const std::string& path =
"")
24496 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24503 case value_t::array:
24507 while (i <
source.size() && i < target.
size())
24511 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24520 while (i <
source.size())
24533 while (i < target.
size())
24539 {
"value", target[i]}
24547 case value_t::object:
24550 for (
auto it =
source.cbegin(); it !=
source.cend(); ++it)
24555 if (target.
find(it.key()) != target.
end())
24558 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
24559 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24566 {
"op",
"remove"}, {
"path", path_key}
24572 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
24580 {
"op",
"add"}, {
"path", path_key},
24581 {
"value", it.value()}
24589 case value_t::null:
24590 case value_t::string:
24591 case value_t::boolean:
24592 case value_t::number_integer:
24593 case value_t::number_unsigned:
24594 case value_t::number_float:
24595 case value_t::binary:
24596 case value_t::discarded:
24602 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24629 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
24631 if (it.value().is_null())
24643 *
this = apply_patch;
24660inline namespace json_literals
24666#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24667 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
24669 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
24672 return nlohmann::json::parse(s, s + n);
24678#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24703 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
24705 return nlohmann::detail::hash(j);
24711struct less< ::nlohmann::detail::value_t>
24718 ::nlohmann::detail::value_t rhs)
const noexcept
24720#if JSON_HAS_THREE_WAY_COMPARISON
24721 return std::is_lt(lhs <=> rhs);
24723 return ::nlohmann::detail::operator<(lhs, rhs);
24729#ifndef JSON_HAS_CPP_20
24734inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
24735 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24736 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24745#if JSON_USE_GLOBAL_UDLS
24746 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24747 using nlohmann::literals::json_literals::operator
""_json;
24748 using nlohmann::literals::json_literals::operator
""_json_pointer;
24750 using nlohmann::literals::json_literals::operator
"" _json;
24751 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24767#if defined(__clang__)
24768 #pragma clang diagnostic pop
24773#undef JSON_INTERNAL_CATCH
24775#undef JSON_PRIVATE_UNLESS_TESTED
24776#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24777#undef NLOHMANN_BASIC_JSON_TPL
24778#undef JSON_EXPLICIT
24779#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24780#undef JSON_INLINE_VARIABLE
24781#undef JSON_NO_UNIQUE_ADDRESS
24782#undef JSON_DISABLE_ENUM_SERIALIZATION
24783#undef JSON_USE_GLOBAL_UDLS
24785#ifndef JSON_TEST_KEEP_MACROS
24788 #undef JSON_HAS_CPP_11
24789 #undef JSON_HAS_CPP_14
24790 #undef JSON_HAS_CPP_17
24791 #undef JSON_HAS_CPP_20
24792 #undef JSON_HAS_FILESYSTEM
24793 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24794 #undef JSON_HAS_THREE_WAY_COMPARISON
24795 #undef JSON_HAS_RANGES
24796 #undef JSON_HAS_STATIC_RTTI
24797 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24811#undef JSON_HEDLEY_ALWAYS_INLINE
24812#undef JSON_HEDLEY_ARM_VERSION
24813#undef JSON_HEDLEY_ARM_VERSION_CHECK
24814#undef JSON_HEDLEY_ARRAY_PARAM
24815#undef JSON_HEDLEY_ASSUME
24816#undef JSON_HEDLEY_BEGIN_C_DECLS
24817#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24818#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24819#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24820#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24821#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24822#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24823#undef JSON_HEDLEY_CLANG_HAS_WARNING
24824#undef JSON_HEDLEY_COMPCERT_VERSION
24825#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24826#undef JSON_HEDLEY_CONCAT
24827#undef JSON_HEDLEY_CONCAT3
24828#undef JSON_HEDLEY_CONCAT3_EX
24829#undef JSON_HEDLEY_CONCAT_EX
24830#undef JSON_HEDLEY_CONST
24831#undef JSON_HEDLEY_CONSTEXPR
24832#undef JSON_HEDLEY_CONST_CAST
24833#undef JSON_HEDLEY_CPP_CAST
24834#undef JSON_HEDLEY_CRAY_VERSION
24835#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24836#undef JSON_HEDLEY_C_DECL
24837#undef JSON_HEDLEY_DEPRECATED
24838#undef JSON_HEDLEY_DEPRECATED_FOR
24839#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24840#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24841#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24842#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24843#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24844#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24845#undef JSON_HEDLEY_DIAGNOSTIC_POP
24846#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24847#undef JSON_HEDLEY_DMC_VERSION
24848#undef JSON_HEDLEY_DMC_VERSION_CHECK
24849#undef JSON_HEDLEY_EMPTY_BASES
24850#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24851#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24852#undef JSON_HEDLEY_END_C_DECLS
24853#undef JSON_HEDLEY_FLAGS
24854#undef JSON_HEDLEY_FLAGS_CAST
24855#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24856#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24857#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24858#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24859#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24860#undef JSON_HEDLEY_GCC_HAS_FEATURE
24861#undef JSON_HEDLEY_GCC_HAS_WARNING
24862#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24863#undef JSON_HEDLEY_GCC_VERSION
24864#undef JSON_HEDLEY_GCC_VERSION_CHECK
24865#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24866#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24867#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24868#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24869#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24870#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24871#undef JSON_HEDLEY_GNUC_HAS_WARNING
24872#undef JSON_HEDLEY_GNUC_VERSION
24873#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24874#undef JSON_HEDLEY_HAS_ATTRIBUTE
24875#undef JSON_HEDLEY_HAS_BUILTIN
24876#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24877#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24878#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24879#undef JSON_HEDLEY_HAS_EXTENSION
24880#undef JSON_HEDLEY_HAS_FEATURE
24881#undef JSON_HEDLEY_HAS_WARNING
24882#undef JSON_HEDLEY_IAR_VERSION
24883#undef JSON_HEDLEY_IAR_VERSION_CHECK
24884#undef JSON_HEDLEY_IBM_VERSION
24885#undef JSON_HEDLEY_IBM_VERSION_CHECK
24886#undef JSON_HEDLEY_IMPORT
24887#undef JSON_HEDLEY_INLINE
24888#undef JSON_HEDLEY_INTEL_CL_VERSION
24889#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24890#undef JSON_HEDLEY_INTEL_VERSION
24891#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24892#undef JSON_HEDLEY_IS_CONSTANT
24893#undef JSON_HEDLEY_IS_CONSTEXPR_
24894#undef JSON_HEDLEY_LIKELY
24895#undef JSON_HEDLEY_MALLOC
24896#undef JSON_HEDLEY_MCST_LCC_VERSION
24897#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24898#undef JSON_HEDLEY_MESSAGE
24899#undef JSON_HEDLEY_MSVC_VERSION
24900#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24901#undef JSON_HEDLEY_NEVER_INLINE
24902#undef JSON_HEDLEY_NON_NULL
24903#undef JSON_HEDLEY_NO_ESCAPE
24904#undef JSON_HEDLEY_NO_RETURN
24905#undef JSON_HEDLEY_NO_THROW
24906#undef JSON_HEDLEY_NULL
24907#undef JSON_HEDLEY_PELLES_VERSION
24908#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24909#undef JSON_HEDLEY_PGI_VERSION
24910#undef JSON_HEDLEY_PGI_VERSION_CHECK
24911#undef JSON_HEDLEY_PREDICT
24912#undef JSON_HEDLEY_PRINTF_FORMAT
24913#undef JSON_HEDLEY_PRIVATE
24914#undef JSON_HEDLEY_PUBLIC
24915#undef JSON_HEDLEY_PURE
24916#undef JSON_HEDLEY_REINTERPRET_CAST
24917#undef JSON_HEDLEY_REQUIRE
24918#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24919#undef JSON_HEDLEY_REQUIRE_MSG
24920#undef JSON_HEDLEY_RESTRICT
24921#undef JSON_HEDLEY_RETURNS_NON_NULL
24922#undef JSON_HEDLEY_SENTINEL
24923#undef JSON_HEDLEY_STATIC_ASSERT
24924#undef JSON_HEDLEY_STATIC_CAST
24925#undef JSON_HEDLEY_STRINGIFY
24926#undef JSON_HEDLEY_STRINGIFY_EX
24927#undef JSON_HEDLEY_SUNPRO_VERSION
24928#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24929#undef JSON_HEDLEY_TINYC_VERSION
24930#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24931#undef JSON_HEDLEY_TI_ARMCL_VERSION
24932#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24933#undef JSON_HEDLEY_TI_CL2000_VERSION
24934#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24935#undef JSON_HEDLEY_TI_CL430_VERSION
24936#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24937#undef JSON_HEDLEY_TI_CL6X_VERSION
24938#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24939#undef JSON_HEDLEY_TI_CL7X_VERSION
24940#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24941#undef JSON_HEDLEY_TI_CLPRU_VERSION
24942#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24943#undef JSON_HEDLEY_TI_VERSION
24944#undef JSON_HEDLEY_TI_VERSION_CHECK
24945#undef JSON_HEDLEY_UNAVAILABLE
24946#undef JSON_HEDLEY_UNLIKELY
24947#undef JSON_HEDLEY_UNPREDICTABLE
24948#undef JSON_HEDLEY_UNREACHABLE
24949#undef JSON_HEDLEY_UNREACHABLE_RETURN
24950#undef JSON_HEDLEY_VERSION
24951#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24952#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24953#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24954#undef JSON_HEDLEY_VERSION_ENCODE
24955#undef JSON_HEDLEY_WARNING
24956#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24957#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24958#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
Definition json.hpp:19598
constexpr bool is_string() const noexcept
return whether value is a string
Definition json.hpp:20870
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition json.hpp:22103
reference operator[](KeyType &&key)
access specified object element
Definition json.hpp:21671
size_type size() const noexcept
returns the number of elements
Definition json.hpp:22444
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:23877
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.hpp:23809
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition json.hpp:21243
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition json.hpp:22301
reference back()
access the last element
Definition json.hpp:21907
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition json.hpp:20334
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:22317
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition json.hpp:24469
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition json.hpp:23657
const_reference front() const
access the first element
Definition json.hpp:21900
constexpr bool is_array() const noexcept
return whether value is an array
Definition json.hpp:20863
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.hpp:22961
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:21851
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22220
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
Definition json.hpp:19729
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.hpp:23828
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition json.hpp:19673
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition json.hpp:20835
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition json.hpp:19733
data(size_type cnt, const basic_json &val)
Definition json.hpp:23701
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:24072
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
Definition json.hpp:23820
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24117
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition json.hpp:19724
std::size_t size_type
a type to represent container sizes
Definition json.hpp:19716
constexpr bool is_structured() const noexcept
return whether type is structured
Definition json.hpp:20807
const_reference operator[](KeyType &&key) const
access specified object element
Definition json.hpp:21695
const value_type & const_reference
the type of an element const reference
Definition json.hpp:19711
void swap(binary_t &other)
exchanges the values
Definition json.hpp:23038
ReferenceType get_ref()
get a reference value (implicit)
Definition json.hpp:21333
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition json.hpp:22483
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:22907
ReferenceType get_ref() const
get a reference value (implicit)
Definition json.hpp:21344
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition json.hpp:20884
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
Definition json.hpp:23156
reference operator+=(initializer_list_t init)
add an object to an object
Definition json.hpp:22699
void push_back(basic_json &&val)
add an object to an array
Definition json.hpp:22587
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition json.hpp:21640
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:22389
const_reference back() const
access the last element
Definition json.hpp:21916
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition json.hpp:21998
reference operator+=(const basic_json &val)
add an object to an array
Definition json.hpp:22644
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.hpp:22978
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:23973
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:20471
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition json.hpp:22811
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:24057
static allocator_type get_allocator()
returns the allocator associated with the container
Definition json.hpp:19739
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition json.hpp:19864
reference at(KeyType &&key)
access specified object element with bounds checking
Definition json.hpp:21503
iterator end() noexcept
returns an iterator to one past the last element
Definition json.hpp:22292
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition json.hpp:20842
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:22914
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition json.hpp:23836
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:22324
data m_data
Definition json.hpp:23719
void push_back(initializer_list_t init)
add an object to an object
Definition json.hpp:22683
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition json.hpp:20301
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition json.hpp:20512
ValueType & get_to(ValueType &v) const
Definition json.hpp:21310
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:23775
iterator begin() noexcept
returns an iterator to the first element
Definition json.hpp:22267
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
Definition json.hpp:23156
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition json.hpp:21750
const_iterator cend() const noexcept
returns an iterator to one past the last element
Definition json.hpp:22308
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:24027
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24159
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition json.hpp:20482
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition json.hpp:20322
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:23861
basic_json flatten() const
return flattened JSON value
Definition json.hpp:24173
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:23988
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition json.hpp:22114
const binary_t & get_binary() const
get a binary value
Definition json.hpp:21415
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition json.hpp:22831
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
Definition json.hpp:24198
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:21803
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition json.hpp:24479
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24131
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition json.hpp:19840
value_type & reference
the type of an element reference
Definition json.hpp:19709
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition json.hpp:22237
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:23745
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition json.hpp:23852
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
Definition json.hpp:22150
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition json.hpp:20460
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition json.hpp:21541
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition json.hpp:19747
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition json.hpp:20519
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition json.hpp:22164
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition json.hpp:23736
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition json.hpp:21928
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition json.hpp:22784
NumberFloatType number_float_t
a type for a number (floating-point)
Definition json.hpp:19860
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:21725
AllocatorType< basic_json > allocator_type
the allocator type
Definition json.hpp:19719
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition json.hpp:19722
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition json.hpp:20771
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition json.hpp:24621
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition json.hpp:21297
reference operator[](T *key)
Definition json.hpp:21656
reference at(size_type idx)
access specified array element with bounds checking
Definition json.hpp:21437
iterator find(KeyType &&key)
find an element in a JSON object
Definition json.hpp:22180
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition json.hpp:20849
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition json.hpp:22331
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:23782
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24145
BooleanType boolean_t
a type for a boolean
Definition json.hpp:19848
detail::value_t value_t
Definition json.hpp:19663
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
Definition json.hpp:19827
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:22675
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition json.hpp:22283
reference operator[](typename object_t::key_type key)
access specified object element
Definition json.hpp:21618
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21055
~basic_json() noexcept
destructor
Definition json.hpp:20753
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition json.hpp:22352
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition json.hpp:20401
void swap(typename binary_t::container_type &other)
exchanges the values
Definition json.hpp:23054
binary_t & get_binary()
get a binary value
Definition json.hpp:21403
const_iterator begin() const noexcept
returns an iterator to the first element
Definition json.hpp:22276
constexpr bool is_number() const noexcept
return whether value is a number
Definition json.hpp:20828
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition json.hpp:22882
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:23919
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.hpp:21284
const_reference operator[](T *key) const
Definition json.hpp:21662
data(const value_t v)
Definition json.hpp:23696
reference operator[](size_type idx)
access specified array element
Definition json.hpp:21559
basic_json(const JsonRef &ref)
Definition json.hpp:20640
JSONSerializer< T, SFINAE > json_serializer
Definition json.hpp:19667
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
Definition json.hpp:20730
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
Definition json.hpp:22364
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:23801
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition json.hpp:21321
NumberIntegerType number_integer_t
a type for a number (integer)
Definition json.hpp:19852
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21044
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition json.hpp:21521
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition json.hpp:20877
void swap(object_t &other)
exchanges the values
Definition json.hpp:23006
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition json.hpp:24182
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition json.hpp:22862
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:20493
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:22382
bool empty() const noexcept
checks whether the container is empty.
Definition json.hpp:22405
void swap(array_t &other)
exchanges the values
Definition json.hpp:22990
void erase(const size_type idx)
remove element from a JSON array given an index
Definition json.hpp:22121
reference operator+=(basic_json &&val)
add an object to an array
Definition json.hpp:22612
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition json.hpp:22244
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition json.hpp:20793
reference emplace_back(Args &&... args)
add an object to an array
Definition json.hpp:22708
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:21826
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition json.hpp:20504
StringType string_t
a type for a string
Definition json.hpp:19844
friend class ::nlohmann::detail::parser
Definition json.hpp:19608
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition json.hpp:19836
void push_back(const basic_json &val)
add an object to an array
Definition json.hpp:22620
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:21776
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition json.hpp:21483
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:24042
json_value m_value
the value of the current element
Definition json.hpp:23694
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition json.hpp:22345
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition json.hpp:20821
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22210
reference front()
access the first element
Definition json.hpp:21893
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition json.hpp:20800
constexpr bool is_null() const noexcept
return whether value is null
Definition json.hpp:20814
void clear() noexcept
clears the contents
Definition json.hpp:22526
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:23793
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
Definition json.hpp:23581
basic_json(basic_json &&other) noexcept
move constructor
Definition json.hpp:20713
iter_impl< basic_json > iterator
an iterator for a basic_json container
Definition json.hpp:19727
basic_json(const value_t v)
create an empty value with a given type
Definition json.hpp:20314
const_reference operator[](size_type idx) const
access specified array element
Definition json.hpp:21605
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition json.hpp:19714
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition json.hpp:22804
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition json.hpp:22338
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition json.hpp:19856
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition json.hpp:23642
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition json.hpp:23759
void swap(string_t &other)
exchanges the values
Definition json.hpp:23022
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition json.hpp:20348
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition json.hpp:19731
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition json.hpp:21460
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
Definition json.hpp:19868
basic_json(const basic_json &other)
copy constructor
Definition json.hpp:20644
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:22652
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition json.hpp:22733
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:23752
constexpr bool is_object() const noexcept
return whether value is an object
Definition json.hpp:20856
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:23768
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:23934
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition json.hpp:22765
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition json.hpp:20531
friend std::istream & operator<<(basic_json &j, std::istream &i)
deserialize from stream
Definition json.hpp:23635
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition json.hpp:22228
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition json.hpp:23845
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition json.hpp:22196
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition json.hpp:19665
an internal type for a backed binary type
Definition json.hpp:5979
bool operator!=(const byte_container_with_subtype &rhs) const
Definition json.hpp:6019
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition json.hpp:5985
std::uint64_t subtype_type
Definition json.hpp:5982
bool operator==(const byte_container_with_subtype &rhs) const
Definition json.hpp:6013
BinaryType container_type
Definition json.hpp:5981
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6007
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:5995
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition json.hpp:6034
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition json.hpp:6000
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition json.hpp:6041
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition json.hpp:5990
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition json.hpp:6026
void clear_subtype() noexcept
clears the binary subtype
Definition json.hpp:6048
deserialization of CBOR, MessagePack, and UBJSON values
Definition json.hpp:9368
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition json.hpp:9384
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition json.hpp:9405
binary_reader & operator=(binary_reader &&)=default
general exception of the basic_json class
Definition json.hpp:4418
const int id
the id of the exception
Definition json.hpp:4427
static std::string diagnostics(std::nullptr_t)
Definition json.hpp:4438
static std::string name(const std::string &ename, int id_)
Definition json.hpp:4433
const char * what() const noexcept override
returns the explanatory string
Definition json.hpp:4421
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition json.hpp:4444
exception indicating errors with iterators
Definition json.hpp:4569
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4572
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition json.hpp:13104
iter_impl operator+(difference_type i) const
add to iterator
Definition json.hpp:13687
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition json.hpp:13241
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition json.hpp:13632
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition json.hpp:13231
bool operator<(const iter_impl &other) const
comparison: smaller
Definition json.hpp:13574
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition json.hpp:13614
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition json.hpp:13678
iter_impl & operator--()
pre-decrement (–it)
Definition json.hpp:13484
const object_t::key_type & key() const
return the key of an object iterator
Definition json.hpp:13787
bool operator==(const IterImpl &other) const
comparison: equal
Definition json.hpp:13525
iter_impl operator++(int) &
post-increment (it++)
Definition json.hpp:13422
iter_impl & operator+=(difference_type i)
add to iterator
Definition json.hpp:13641
reference operator[](difference_type n) const
access to successor
Definition json.hpp:13749
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition json.hpp:13134
pointer operator->() const
dereference the iterator
Definition json.hpp:13380
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition json.hpp:13812
difference_type operator-(const iter_impl &other) const
return difference
Definition json.hpp:13720
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
Definition json.hpp:13129
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition json.hpp:13698
reference value() const
return the value of an iterator
Definition json.hpp:13803
bool operator>(const iter_impl &other) const
comparison: greater than
Definition json.hpp:13623
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition json.hpp:13138
iter_impl & operator++()
pre-increment (++it)
Definition json.hpp:13433
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition json.hpp:13132
reference operator*() const
return a reference to the value pointed to by the iterator
Definition json.hpp:13336
iter_impl operator-(difference_type i) const
subtract from iterator
Definition json.hpp:13709
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition json.hpp:13216
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition json.hpp:13565
iter_impl operator--(int) &
post-decrement (it–)
Definition json.hpp:13473
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition json.hpp:13143
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition json.hpp:13206
void set_end() noexcept
set the iterator past the last value
Definition json.hpp:13297
iteration_proxy_value operator++(int) &
Definition json.hpp:5313
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition json.hpp:5322
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition json.hpp:5328
std::ptrdiff_t difference_type
Definition json.hpp:5259
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition json.hpp:5280
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition json.hpp:5305
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
Definition json.hpp:5263
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
Definition json.hpp:5370
const string_type & key() const
return key of the iterator
Definition json.hpp:5334
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition json.hpp:5264
proxy class for the items() function
Definition json.hpp:5378
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition json.hpp:5403
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition json.hpp:5397
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition json.hpp:5387
iteration_proxy & operator=(iteration_proxy const &)=default
Definition json.hpp:15017
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition json.hpp:15025
json_ref(value_type &&value)
Definition json.hpp:15021
value_type const & operator*() const
Definition json.hpp:15056
value_type const * operator->() const
Definition json.hpp:15061
json_ref(std::initializer_list< json_ref > init)
Definition json.hpp:15029
json_ref(Args &&... args)
Definition json.hpp:15036
value_type moved_or_copied() const
Definition json.hpp:15047
BasicJsonType value_type
Definition json.hpp:15019
a template for a reverse iterator class
Definition json.hpp:13866
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition json.hpp:13882
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition json.hpp:13894
json_reverse_iterator & operator++()
pre-increment (++it)
Definition json.hpp:13888
std::ptrdiff_t difference_type
Definition json.hpp:13868
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition json.hpp:13906
reference operator[](difference_type n) const
access to successor
Definition json.hpp:13930
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition json.hpp:13936
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition json.hpp:13924
typename Base::reference reference
the reference type for the pointed-to element
Definition json.hpp:13872
reference value() const
return the value of an iterator
Definition json.hpp:13943
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition json.hpp:13879
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition json.hpp:13900
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition json.hpp:13870
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition json.hpp:13918
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition json.hpp:13875
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition json.hpp:13912
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:7439
bool end_object()
Definition json.hpp:7489
bool start_object(std::size_t=static_cast< std::size_t >(-1))
Definition json.hpp:7479
bool binary(binary_t &)
Definition json.hpp:7474
bool number_integer(number_integer_t)
Definition json.hpp:7454
bool start_array(std::size_t=static_cast< std::size_t >(-1))
Definition json.hpp:7494
bool boolean(bool)
Definition json.hpp:7449
bool null()
Definition json.hpp:7444
bool end_array()
Definition json.hpp:7499
bool number_unsigned(number_unsigned_t)
Definition json.hpp:7459
bool string(string_t &)
Definition json.hpp:7469
typename BasicJsonType::binary_t binary_t
Definition json.hpp:7442
bool number_float(number_float_t, const string_t &)
Definition json.hpp:7464
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition json.hpp:7504
bool key(string_t &)
Definition json.hpp:7484
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:7438
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:7440
typename BasicJsonType::string_t string_t
Definition json.hpp:7441
bool boolean(bool val)
Definition json.hpp:7160
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:7317
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true)
Definition json.hpp:7139
typename BasicJsonType::string_t string_t
Definition json.hpp:7134
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:7178
constexpr bool is_errored() const
Definition json.hpp:7329
bool string(string_t &val)
Definition json.hpp:7184
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:7132
typename BasicJsonType::binary_t binary_t
Definition json.hpp:7135
bool start_object(std::size_t len)
Definition json.hpp:7196
bool start_array(std::size_t len)
Definition json.hpp:7267
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:7131
bool end_array()
Definition json.hpp:7284
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool key(string_t &val)
Definition json.hpp:7214
bool end_object()
Definition json.hpp:7231
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
Definition json.hpp:7137
typename BasicJsonType::parser_callback_t parser_callback_t
Definition json.hpp:7136
bool null()
Definition json.hpp:7154
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:7172
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:7133
bool number_integer(number_integer_t val)
Definition json.hpp:7166
bool binary(binary_t &val)
Definition json.hpp:7190
SAX implementation to create a JSON value from SAX events.
Definition json.hpp:6946
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
Definition json.hpp:7000
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition json.hpp:6959
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:7067
bool null()
Definition json.hpp:6970
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
Definition json.hpp:6951
bool start_object(std::size_t len)
Definition json.hpp:7012
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:6949
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:6988
bool number_integer(number_integer_t val)
Definition json.hpp:6982
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:6948
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
Definition json.hpp:7006
json_sax_dom_parser(json_sax_dom_parser &&)=default
bool boolean(bool val)
Definition json.hpp:6976
bool end_array()
Definition json.hpp:7056
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:6994
bool end_object()
Definition json.hpp:7034
constexpr bool is_errored() const
Definition json.hpp:7079
typename BasicJsonType::binary_t binary_t
Definition json.hpp:6952
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:6950
bool start_array(std::size_t len)
Definition json.hpp:7044
bool key(string_t &val)
Definition json.hpp:7024
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition json.hpp:7580
token_type
token types for the parser
Definition json.hpp:7557
lexical analysis
Definition json.hpp:7630
bool skip_bom()
skip the UTF-8 byte order mark
Definition json.hpp:9012
void skip_whitespace()
Definition json.hpp:9026
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition json.hpp:7641
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition json.hpp:8999
std::string get_token_string() const
Definition json.hpp:8974
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition json.hpp:8933
constexpr position_t get_position() const noexcept
return position of last read token
Definition json.hpp:8966
token_type scan()
Definition json.hpp:9035
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition json.hpp:8939
typename lexer_base< BasicJsonType >::token_type token_type
Definition json.hpp:7639
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition json.hpp:8951
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition json.hpp:8945
exception indicating other library errors
Definition json.hpp:4621
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4624
exception indicating access out of the defined range
Definition json.hpp:4604
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4607
exception indicating a parse error
Definition json.hpp:4516
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition json.hpp:4528
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4536
const std::size_t byte
byte index of the parse error
Definition json.hpp:4553
Definition json.hpp:18257
std::array< char, 512 > string_buffer
string buffer
Definition json.hpp:19181
std::uint8_t state
Definition json.hpp:18599
std::size_t bytes_after_last_accept
Definition json.hpp:18603
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition json.hpp:18272
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition json.hpp:18597
std::size_t undumped_chars
Definition json.hpp:18604
const char thousands_sep
the locale's thousand separator character
Definition json.hpp:19176
const char decimal_point
the locale's decimal point character
Definition json.hpp:19178
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition json.hpp:19189
string_t indent_string
the indentation string
Definition json.hpp:19186
const std::lconv * loc
the locale
Definition json.hpp:19174
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition json.hpp:19171
const char indent_char
the indentation character
Definition json.hpp:19184
std::size_t bytes
Definition json.hpp:18600
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition json.hpp:18312
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition json.hpp:4587
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4590
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition json.hpp:14038
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition json.hpp:14133
typename string_t_helper< RefStringType >::type string_t
Definition json.hpp:14060
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition json.hpp:14140
json_pointer(const string_t &s="")
create JSON pointer
Definition json.hpp:14064
bool empty() const noexcept
return whether pointer points to the root document
Definition json.hpp:14199
friend bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for equality
Definition json.hpp:14933
void pop_back()
remove last reference token
Definition json.hpp:14161
string_t to_string() const
return a string representation of the JSON pointer
Definition json.hpp:14070
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition json.hpp:14118
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14192
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition json.hpp:14100
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition json.hpp:14125
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition json.hpp:14147
friend bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for inequality
Definition json.hpp:14958
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition json.hpp:14110
friend class json_pointer
Definition json.hpp:14044
const string_t & back() const
return last reference token
Definition json.hpp:14173
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition json.hpp:14091
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14185
friend bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointer for less-than
Definition json.hpp:14983
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition json.hpp:5451
GLint ref
Definition glad.h:958
const GLdouble * v
Definition glad.h:1378
GLubyte GLubyte GLubyte GLubyte w
Definition glad.h:1438
GLboolean * data
Definition glad.h:979
GLuint GLsizei GLsizei * length
Definition glad.h:1252
GLint GLint GLsizei GLint GLenum format
Definition glad.h:910
GLuint GLuint end
Definition glad.h:1068
GLuint index
Definition glad.h:1225
GLuint const GLchar * name
Definition glad.h:1225
GLint GLsizei count
Definition glad.h:1025
GLint GLint GLsizei GLint GLenum GLenum type
Definition glad.h:910
GLint y
Definition glad.h:895
GLboolean GLboolean GLboolean b
Definition glad.h:1512
GLsizei GLsizei GLchar * source
Definition glad.h:1276
GLsizeiptr size
Definition glad.h:1182
GLuint buffer
Definition glad.h:1170
GLint GLenum GLint x
Definition glad.h:1034
GLsizei const GLfloat * value
Definition glad.h:1339
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean r
Definition glad.h:1512
GLuint start
Definition glad.h:1068
GLsizei const GLchar *const * string
Definition glad.h:1309
GLboolean GLboolean GLboolean GLboolean a
Definition glad.h:1512
GLint first
Definition glad.h:1025
GLintptr offset
Definition glad.h:1185
GLdouble f
Definition glad.h:1015
GLM_FUNC_QUALIFIER vec< L, T, Q > exp(vec< L, T, Q > const &x)
Definition func_exponential.inl:80
GLM_FUNC_DECL GLM_CONSTEXPR genType e()
Definition constants.inl:108
uint64 uint64_t
Definition fwd.hpp:145
int64 int64_t
Definition fwd.hpp:85
uint32 uint32_t
Definition fwd.hpp:131
uint8 uint8_t
Definition fwd.hpp:103
uint16 uint16_t
Definition fwd.hpp:117
genType::value_type const * begin(genType const &v)
Definition range.hpp:68
detail::uint8 byte
Definition raw_data.hpp:32
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition json.hpp:2604
#define JSON_HEDLEY_CONST
Definition json.hpp:1822
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition json.hpp:1106
#define JSON_INLINE_VARIABLE
Definition json.hpp:2503
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition json.hpp:1452
#define JSON_PRIVATE_UNLESS_TESTED
Definition json.hpp:2563
#define NLOHMANN_JSON_VERSION_PATCH
Definition json.hpp:70
#define JSON_HEDLEY_LIKELY(expr)
Definition json.hpp:1717
#define JSON_HEDLEY_NON_NULL(...)
Definition json.hpp:1610
#define JSON_INTERNAL_CATCH(exception)
Definition json.hpp:2530
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.hpp:24653
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition json.hpp:2051
#define JSON_CATCH(exception)
Definition json.hpp:2529
#define JSON_ASSERT(x)
Definition json.hpp:2556
#define JSON_THROW(exception)
Definition json.hpp:2527
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition json.hpp:77
#define NLOHMANN_JSON_VERSION_MAJOR
Definition json.hpp:68
#define NLOHMANN_BASIC_JSON_TPL
Definition json.hpp:2614
#define JSON_HEDLEY_UNLIKELY(expr)
Definition json.hpp:1718
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition json.hpp:12307
#define JSON_TRY
Definition json.hpp:2528
#define NLOHMANN_JSON_NAMESPACE_END
Definition json.hpp:144
#define JSON_NO_UNIQUE_ADDRESS
Definition json.hpp:2509
#define NLOHMANN_JSON_VERSION_MINOR
Definition json.hpp:69
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition json.hpp:2820
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition json.hpp:134
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
Definition json.hpp:12304
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition json.hpp:1107
#define JSON_EXPLICIT
Definition json.hpp:2857
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition json.hpp:1400
#define JSON_HEDLEY_PURE
Definition json.hpp:1791
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:14983
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition json.hpp:23079
constexpr bool is_transparent()
Definition json.hpp:4228
constexpr bool is_c_string()
Definition json.hpp:4200
detail namespace with internal helper functions
Definition json.hpp:253
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition json.hpp:5868
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition json.hpp:313
typename make_void< Ts... >::type void_t
Definition json.hpp:259
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition json.hpp:4309
OutStringType concat(Args &&... args)
Definition json.hpp:4383
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition json.hpp:4318
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition json.hpp:3551
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
Definition json.hpp:3256
decltype(std::declval< T >().template get< U >()) get_template_function
Definition json.hpp:3557
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition json.hpp:4050
typename T::pointer pointer_t
Definition json.hpp:3542
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition json.hpp:4312
integer_sequence< size_t, Ints... > index_sequence
Definition json.hpp:3171
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition json.hpp:3217
typename T::value_type value_type_t
Definition json.hpp:3536
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition json.hpp:317
T conditional_static_cast(U value)
Definition json.hpp:4084
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition json.hpp:4324
typename std::enable_if< B, T >::type enable_if_t
Definition json.hpp:3129
typename T::mapped_type mapped_type_t
Definition json.hpp:3530
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition json.hpp:3005
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition json.hpp:3778
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition json.hpp:5413
cbor_tag_handler_t
how to treat CBOR tags
Definition json.hpp:9341
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition json.hpp:310
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition json.hpp:3554
make_integer_sequence< size_t, N > make_index_sequence
Definition json.hpp:3225
std::integral_constant< bool, Value > bool_constant
Definition json.hpp:4190
void concat_into(OutStringType &)
Definition json.hpp:4299
typename T::key_type key_type_t
Definition json.hpp:3533
constexpr bool value_in_range_of(T val)
Definition json.hpp:4184
value_t
the JSON type enumeration
Definition json.hpp:2907
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition json.hpp:4107
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition json.hpp:304
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition json.hpp:4034
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition json.hpp:4315
typename T::iterator_category iterator_category_t
Definition json.hpp:3548
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition json.hpp:2936
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition json.hpp:4062
error_handler_t
how to treat decoding errors
Definition json.hpp:18249
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
std::size_t concat_length()
Definition json.hpp:4268
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition json.hpp:3781
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition json.hpp:3630
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition json.hpp:4303
void to_json(BasicJsonType &j, T b) noexcept
Definition json.hpp:5729
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition json.hpp:3233
typename T::difference_type difference_type_t
Definition json.hpp:3539
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition json.hpp:3115
typename T::is_transparent detect_is_transparent
Definition json.hpp:4020
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition json.hpp:13992
typename T::reference reference_t
Definition json.hpp:3545
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition json.hpp:4053
typename T::key_compare detect_key_compare
Definition json.hpp:3614
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition json.hpp:4321
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition json.hpp:298
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3024
void int_to_string(string_type &target, std::size_t value)
Definition json.hpp:5250
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition json.hpp:4112
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition json.hpp:4306
GLM_FUNC_QUALIFIER vec< 3, T, Q > combine(vec< 3, T, Q > const &a, vec< 3, T, Q > const &b, T ascl, T bscl)
Make a linear combination of two vectors and return the result.
Definition matrix_decompose.inl:13
GLM_FUNC_DECL GLM_CONSTEXPR mat< 2, 2, T, Q > operator-(mat< 2, 2, T, Q > const &m)
Definition type_mat2x2.inl:355
GLM_FUNC_DECL GLM_CONSTEXPR bool operator==(mat< 2, 2, T, Q > const &m1, mat< 2, 2, T, Q > const &m2)
Definition type_mat2x2.inl:526
GLM_FUNC_DECL GLM_CONSTEXPR bool operator!=(mat< 2, 2, T, Q > const &m1, mat< 2, 2, T, Q > const &m2)
Definition type_mat2x2.inl:532
GLM_FUNC_DECL GLM_CONSTEXPR mat< 2, 2, T, Q > operator+(mat< 2, 2, T, Q > const &m)
Definition type_mat2x2.inl:349
Definition json.hpp:24659
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:24734
namespace for Niels Lohmann
Definition json.hpp:5921
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition json.hpp:5945
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition json.hpp:5935
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition json.hpp:5925
typename BasicJsonType::object_t object_t
Definition json.hpp:3623
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition json.hpp:3624
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition json.hpp:3626
signed char char_type
Definition json.hpp:3669
static constexpr int_type eof() noexcept
Definition json.hpp:3683
uint64_t int_type
Definition json.hpp:3670
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3678
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3673
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3654
static constexpr int_type eof() noexcept
Definition json.hpp:3659
unsigned char char_type
Definition json.hpp:3645
uint64_t int_type
Definition json.hpp:3646
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3649
std::true_type value_t
Definition json.hpp:293
Op< Args... > type
Definition json.hpp:294
std::false_type value_t
Definition json.hpp:286
Default type
Definition json.hpp:287
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition json.hpp:5638
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition json.hpp:5613
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition json.hpp:5603
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition json.hpp:5625
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition json.hpp:5654
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition json.hpp:5542
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition json.hpp:5551
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition json.hpp:5496
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition json.hpp:5564
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition json.hpp:5590
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition json.hpp:5577
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition json.hpp:5673
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition json.hpp:5694
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition json.hpp:5683
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition json.hpp:5518
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition json.hpp:5529
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition json.hpp:5509
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3576
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3591
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3606
T value_type
Definition json.hpp:3158
static constexpr std::size_t size() noexcept
Definition json.hpp:3159
an iterator value
Definition json.hpp:13037
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition json.hpp:13041
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition json.hpp:13043
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition json.hpp:13039
std::numeric_limits< RealIntegerType > RealLimits
Definition json.hpp:3952
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition json.hpp:3953
typename BasicJsonType::object_t object_t
Definition json.hpp:3803
static constexpr auto value
Definition json.hpp:3853
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition json.hpp:3924
typename BasicJsonType::object_t object_t
Definition json.hpp:3827
ConstructibleStringType laundered_type
Definition json.hpp:3864
static constexpr auto value
Definition json.hpp:3867
static one test(decltype(&C::capacity))
char one
Definition json.hpp:4069
static constexpr bool value
Definition json.hpp:3774
T value_type
Definition json.hpp:3338
T * pointer
Definition json.hpp:3340
ptrdiff_t difference_type
Definition json.hpp:3339
T & reference
Definition json.hpp:3341
std::random_access_iterator_tag iterator_category
Definition json.hpp:3337
typename It::iterator_category iterator_category
Definition json.hpp:3318
typename It::difference_type difference_type
Definition json.hpp:3314
typename It::value_type value_type
Definition json.hpp:3315
typename It::reference reference
Definition json.hpp:3317
typename It::pointer pointer
Definition json.hpp:3316
Default base class of the basic_json class.
Definition json.hpp:13985
void type
Definition json.hpp:257
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
struct to capture the start position of the current token
Definition json.hpp:3070
std::size_t chars_read_current_line
the number of characters read in the current line
Definition json.hpp:3074
std::size_t lines_read
the number of lines read
Definition json.hpp:3076
std::size_t chars_read_total
the total number of characters read
Definition json.hpp:3072
static JSON_INLINE_VARIABLE constexpr T value
Definition json.hpp:3247
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition json.hpp:5890
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition json.hpp:3198
static constexpr bool test(T val)
Definition json.hpp:4168
static constexpr bool test(T)
Definition json.hpp:4177
static constexpr bool test(T val)
Definition json.hpp:4122
static constexpr bool test(T val)
Definition json.hpp:4142
static constexpr bool test(T val)
Definition json.hpp:4132
static constexpr bool test(T val)
Definition json.hpp:4152
SAX interface.
Definition json.hpp:6816
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:6817
typename BasicJsonType::string_t string_t
Definition json.hpp:6820
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:6819
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:6818
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition json.hpp:6821
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
Definition json.hpp:19231
std::vector< std::pair< const Key, T >, Allocator > Container
Definition json.hpp:19234
std::pair< iterator, bool > insert(value_type &&value)
Definition json.hpp:19525
typename Container::value_type value_type
Definition json.hpp:19238
std::equal_to< Key > key_compare
Definition json.hpp:19242
iterator erase(iterator pos)
Definition json.hpp:19403
T mapped_type
Definition json.hpp:19233
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition json.hpp:19248
T & operator[](KeyType &&key)
Definition json.hpp:19290
typename Container::iterator iterator
Definition json.hpp:19235
const T & at(KeyType &&key) const
Definition json.hpp:19350
T & at(KeyType &&key)
Definition json.hpp:19322
const T & operator[](KeyType &&key) const
Definition json.hpp:19302
iterator find(const key_type &key)
Definition json.hpp:19487
iterator erase(iterator first, iterator last)
Definition json.hpp:19408
const T & at(const key_type &key) const
Definition json.hpp:19335
const_iterator find(const key_type &key) const
Definition json.hpp:19513
T & operator[](const key_type &key)
Definition json.hpp:19283
size_type erase(KeyType &&key)
Definition json.hpp:19384
typename Container::size_type size_type
Definition json.hpp:19237
ordered_map() noexcept(noexcept(Container()))
Definition json.hpp:19247
void insert(InputIt first, InputIt last)
Definition json.hpp:19548
size_type count(const key_type &key) const
Definition json.hpp:19461
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition json.hpp:19270
size_type erase(const key_type &key)
Definition json.hpp:19363
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition json.hpp:19252
std::pair< iterator, bool > insert(const value_type &value)
Definition json.hpp:19530
size_type count(KeyType &&key) const
Definition json.hpp:19475
Key key_type
Definition json.hpp:19232
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition json.hpp:19250
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition json.hpp:19545
const T & operator[](const key_type &key) const
Definition json.hpp:19295
iterator find(KeyType &&key)
Definition json.hpp:19501
T & at(const key_type &key)
Definition json.hpp:19307
typename Container::const_iterator const_iterator
Definition json.hpp:19236
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition json.hpp:19255
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition json.hpp:24703
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition json.hpp:24717